I am trying to build this app but I am getting one error. It looks like gradle setting error. So I have provided the gradle settings from the app - android-studio-3.4

build failed 6 s 131 ms
Run build 6 s 53 ms
Load build 4 ms
Configure build 155 ms
Calculate task graph 86 ms
Run tasks 5 s 805 ms
null
com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Android-nRF-Toolbox-developNEW\Android-nRF-Toolbox-develop\app\build\intermediates\transforms\instantRun\debug\0
com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
com.android.tools.r8.CompilationFailedException: Compilation failed to complete
com.android.tools.r8.utils.AbortException: Error: Invoke-customs are only supported starting with Android O (--min-api 26)
I have tried to put the version of JAVA 8.
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "no.nordicsemi.android.nrftoolbox"
minSdkVersion 18
targetSdkVersion 28
versionCode 69
versionName "2.7.2"
resConfigs "en"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
debug {
minifyEnabled true
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation project(':common')
implementation fileTree(dir: 'libs', include: ['*.jar'])
wearApp project(path: ':wear')
// nRF Toolbox is using Play Service 10.2.0 in order to make the app working in China:
// https://developer.android.com/training/wearables/apps/creating-app-china.html
//noinspection GradleDependency
implementation 'com.google.android.gms:play-services-wearable:10.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha04'
implementation 'androidx.preference:preference:1.1.0-alpha04'
implementation 'com.google.android.material:material:1.1.0-alpha05'
implementation 'no.nordicsemi.android:log:2.2.0'
implementation 'no.nordicsemi.android.support.v18:scanner:1.4.0'
// The DFU Library is imported automatically from jcenter:
implementation 'no.nordicsemi.android:dfu:1.9.0'
// if you desire to build the DFU Library, clone the
// https://github.com/NordicSemiconductor/Android-DFU-Library project into DFULibrary folder,
// add it as a module into the project structure and uncomment the following line
// (and also the according lines in the settings.gradle):
// implementation project(':dfu')
// Import the BLE Common Library.
// The BLE Common Library depends on BLE Library. It is enough to include the first one.
implementation 'no.nordicsemi.android:ble-common:2.1.1'
// The BLE Common Library may be included from jcenter. If you want to modify the code,
// clone both projects from GitHub and replace the line above with the following
// (and also the according lines in the settings.gradle):
// implementation project(':ble-common')
implementation('org.simpleframework:simple-xml:2.7.1') {
exclude group: 'stax', module: 'stax-api'
exclude group: 'xpp3', module: 'xpp3'
}
}

Related

Module not found: Can't resolve 'fs' - NextJS

I'm trying to use node-jsencrypt with NextJS (tsx):
index.tsx
import JSEncrypt from 'node-jsencrypt';
package.json
"node-jsencrypt": "^1.0.0"
Log
error - ./node_modules/node-jsencrypt/index.js:2:0
Module not found: Can't resolve 'fs'
Notes:
I didn't find the 'webpack.config.js' file, as I saw in some topics.
Ok, I played around with this issue & I think I have what cover all possible combinations. In the repo you can find working examples. There are 3 possible approaches, and the right one will depend on what's already in your project - details that were unspecified in the original question.
Solution while using webpack 5 next.config.js
module.exports = {
future: {
webpack5: true, // by default, if you customize webpack config, they switch back to version 4.
// Looks like backward compatibility approach.
},
webpack(config) {
config.resolve.fallback = {
...config.resolve.fallback, // if you miss it, all the other options in fallback, specified
// by next.js will be dropped. Doesn't make much sense, but how it is
fs: false, // the solution
};
return config;
},
};
Solution while using webpack 4 - next.config.js
module.exports = {
webpack(config) { // we depend on nextjs switching to webpack 4 by default. Probably they will
// change this behavior at some future major version.
config.node = {
fs: "empty", // webpack4 era solution
};
return config;
},
};
You could consider using other library. According to node-jsencrypt readme they are node port of jsencrypt, and here I assume you try to build for browser. The node library got stuck at version 1, while the original library is already at version 3. As I checked in the last commit on main, if you use this library, it's building just fine without any issues.
Original, nextjs unaware answer:
Since version 5, webpack doesn't include polyfiles for node libraries. In your case, you most likely need to add resolve.fallback.fs: false to your webpack config.
More about this option- https://webpack.js.org/configuration/resolve/#resolvefallback
It mentioned in v4 to v6 migration guide, if this is your case:
https://webpack.js.org/migrate/5/
In the next.config.js file add the code below
build: {
extend(config, {}) {
config.node = {
fs: 'empty'
}
}
},

NoSuchMethodError for com.google.api.Service.hasQuota after appengineDeploy

After deploying my Google Endpoints API I get the error below even if I hit just the server url / or /_ah/warmup
Uncaught exception from servlet
java.lang.NoSuchMethodError: com.google.api.Service.hasQuota()Z
at com.google.api.control.model.MethodRegistry.extractQuota(MethodRegistry.java:290)
at com.google.api.control.model.MethodRegistry.<init>(MethodRegistry.java:72)
at com.google.api.control.ConfigFilter.init(ConfigFilter.java:89)
The crazy thing is that this happens intermittently. Sometimes the deploy just works, but most times it fails.
This used to work fine as is until March 1st, so I rolled back the gcloud components version as well, but still get the same error.
Tried upgrading to the latest version if the appengine and endpoints libaries, but still get the error below.
EDIT-1
Here is the build.gradle for reference
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
// App Engine Gradle plugin
classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.1'
// Endpoints Frameworks Gradle plugin
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:2.1.0'
}
}
// Dev
def projectIdValue = 'dev-sample-api'
repositories {
mavenCentral()
jcenter()
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceSets {
main {
java {
srcDirs 'src/main/java'
}
}
}
dependencies {
// App Engine API
implementation group: 'com.google.appengine', name: 'appengine-api-1.0-sdk', version: '1.9.86'
// Endpoints Frameworks v2.0
implementation ('com.google.endpoints:endpoints-framework:2.2.2') {
exclude group: 'org.slf4j', module: 'slf4j-nop'
}
implementation group: 'com.google.endpoints', name: 'endpoints-management-control-appengine', version: '1.0.14'
implementation group: 'com.google.endpoints', name: 'endpoints-framework-auth', version: '1.0.14'
implementation group: 'com.google.protobuf', name: 'protobuf-java-util', version: '3.15.6'
implementation group: 'io.grpc', name: 'grpc-stub', version: '1.36.0'
implementation group: 'io.grpc', name: 'grpc-protobuf', version: '1.36.0'
// App Engine and Endpoint dependencies
compileOnly 'javax.servlet:javax.servlet-api:3.1.0'
implementation 'jstl:jstl:1.2'
implementation group: 'javax.inject', name: 'javax.inject', version: '1'
// Logging
implementation 'org.slf4j:slf4j-api:1.7.30'
implementation 'org.slf4j:slf4j-jdk14:1.7.30'
// Objectify for data storage and access
implementation 'com.googlecode.objectify:objectify:5.1.9'
// Common Utils and Libraries
implementation 'com.google.guava:guava:20.0'
implementation 'commons-validator:commons-validator:1.6'
implementation 'joda-time:joda-time:2.10.8'
implementation group: 'com.darwinsys', name: 'hirondelle-date4j', version: '1.5.1'
}
endpointsServer {
// Endpoints Framework Plugin server-side configuration
hostname = "${projectIdValue}.appspot.com"
}
// this replaces the ${endpoints.project.id} in appengine-web.xml and web.xml
task replaceProjectId(type: Copy) {
from 'src/main/webapp/WEB-INF/'
include '*.xml'
into "build/exploded-${archivesBaseName}/WEB-INF"
expand(endpoints:[project:[id:projectIdValue]])
filteringCharset = 'UTF-8'
}
assemble.dependsOn replaceProjectId
appengine {
deploy { // deploy configuration
version = "GCLOUD_CONFIG"
projectId = "GCLOUD_CONFIG"
def promoteProp = findProperty("appengine.deploy.promote")
if (promoteProp != null) {
promote = new Boolean(promoteProp)
}
}
run {
host = "0.0.0.0"
port = 8080
}
}
Just for the records - correct command line would be:
gcloud components update
Closing this based on suggestion by #RafaelLemos.
"Maybe this was a problem with an older version of some component"
Not reproducible. Probable fix
gcloud components update

React-native-camera error when compiling android

I tried to upgrade my react native project to the newest version (0.59.2). Unfortunately, now when trying to run react-native run-android im getting this error:
Could not determine the dependencies of task ':app:preDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not resolve project :react-native-camera.
Required by:
project :app
> Cannot choose between the following variants of project :react-native-camera:
- generalDebugRuntimeElements
- mlkitDebugRuntimeElements
All of them match the consumer attributes:
- Variant 'generalDebugRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.android.build.api.attributes.VariantAttr 'generalDebug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
- Found react-native-camera 'general' but wasn't required.
- Variant 'mlkitDebugRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.android.build.api.attributes.VariantAttr 'mlkitDebug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
- Found react-native-camera 'mlkit' but wasn't required.
I have already tried to create a new project however this results in the same error.
Reinstalling the node modules didn't help either.
On iOS it works fine.
Insert the following lines in android/app/build.gradle
android {
...
defaultConfig {
...
missingDimensionStrategy 'react-native-camera', 'general' <-- insert this line
}
}
Please insert the following line in android/app/build.gradle inside defaultConfig block either
missingDimensionStrategy 'react-native-camera', 'general'
or
missingDimensionStrategy 'react-native-camera', 'mlkit'
Add jitpack to android/build.gradle
allprojects {
repositories {
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
}
}
Complete guide
Could not resolve project :react-native-camera. on Android
Hope this helps.
Step 1:
Change the class path in android/build.gradle in dependencies tag to this:
classpath 'com.android.tools.build:gradle:3.3.0'
Step:2:
Change the gradle version in android/gradle/wrapper/gradle-wrapper.properties to this:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
Step 3:
In the android/app/build.gradle add this at the top:
defaultConfig {
missingDimensionStrategy 'react-native-camera', 'general'
}
}
Step 4:
Also add these two lines:
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
Camera works now.
It is simple to resolve by adding missingDimensionStrategy attribute in defaultConfig tag in android/app/build.gradle.
android {
...
defaultConfig {
...
missingDimensionStrategy 'react-native-camera', 'general'
}
}
If you are still having the same issue then you have to do the following steps.
Ensure that your gradle build tool version is greater than 3.3.0. You can use 3.4.1 for this purpose. Change the gradle build tool version from android/build.gradle file buildscript dependencies attributes.
buildscript {
...
dependencies {
classpath("com.android.tools.build:gradle:3.4.1")
}
}
Also have to change the gradle wrapper to 4.4 or later. You can change the gradle version in android/gradle/wrapper/gradle-wrapper.properties to this
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
Finally add the following lines in repositories tag of android/build.gradle
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }

Datanucleus enhancer stops working after upgrading Google App Engine to Java 8

We received an email from Google App Engine to upgrade to Java 8 from Java 7. We have followed the steps in:
https://cloud.google.com/appengine/docs/standard/java/migrating-to-java8
But after deploying our App Engine back-end it fails to start with the following error:
org.datanucleus.metadata.MetaDataManager initialiseFileMetaDataForUse:
Found Meta-Data for class ... but this class
is not enhanced!! Please enhance the class before running DataNucleus.
(MetaDataManager.java:1144)
org.datanucleus.exceptions.NucleusUserException: Found Meta-Data for
class ... but this class is not enhanced!!
Please enhance the class before running DataNucleus. at
org.datanucleus.metadata.MetaDataManager.initialiseClassMetaData(MetaDataManager.java:2593)
at
org.datanucleus.metadata.MetaDataManager.initialiseFileMetaData(MetaDataManager.java:2544)
at
org.datanucleus.metadata.MetaDataManager.initialiseFileMetaDataForUse(MetaDataManager.java:1140)
at
org.datanucleus.metadata.MetaDataManager.loadPersistenceUnit(MetaDataManager.java:986)
at
org.datanucleus.api.jpa.JPAEntityManagerFactory.initialiseNucleusContext(JPAEntityManagerFactory.java:754)
at
org.datanucleus.api.jpa.JPAEntityManagerFactory.initialise(JPAEntityManagerFactory.java:417)
at
org.datanucleus.api.jpa.JPAEntityManagerFactory.(JPAEntityManagerFactory.java:380)
at
org.datanucleus.api.jpa.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:91)
at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:150)
at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:70)
This is our build.gradle:
buildscript { // Configuration for building
repositories {
mavenCentral()
jcenter() // Bintray's repository - a fast Maven Central mirror & more
}
dependencies {
// App Engine Gradle plugin
classpath 'com.google.cloud.tools:appengine-gradle-plugin:+'
}
}
repositories {
mavenCentral()
jcenter()
}
apply plugin: 'java'
apply plugin: 'war'
//apply plugin: 'appengine'
apply plugin: 'com.google.cloud.tools.appengine' // App Engine tasks
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
appengine { // App Engine tasks configuration
deploy { // deploy configuration
version = findProperty("appengine.deploy.version")
def promoteProp = findProperty("appengine.deploy.promote")
if (promoteProp != null) {
promote = new Boolean(promoteProp)
}
}
}
configurations {
compile.exclude module: 'guava-jdk5'
}
dependencies {
implementation 'jstl:jstl:1.2'
implementation group: 'com.google.appengine', name: 'appengine-api-1.0-sdk', version: '+'
implementation group: 'com.google.endpoints', name: 'endpoints-framework', version: '+'
implementation 'com.google.appengine.orm:datanucleus-appengine:+' //2.1.2'
implementation 'javax.servlet:servlet-api:2.5'
implementation 'javax.inject:javax.inject:1'
implementation 'javax.transaction:jta:1.1'
implementation 'com.ganyo:gcm-server:1.0.2'
implementation 'org.json:json:20140107'
implementation 'org.apache.httpcomponents:httpmime:+'
implementation 'org.apache.geronimo.specs:geronimo-jpa_2.0_spec:1.0'
// Persistence
// implementation 'org.ow2.asm:asm:4.0'
implementation 'javax.jdo:jdo-api:+' //3.0.1'
implementation 'org.datanucleus:datanucleus-api-jpa:3.1.3'
implementation 'org.datanucleus:datanucleus-api-jdo:3.1.3' //5.0.1'
implementation 'org.datanucleus:datanucleus-enhancer:+' //3.1.1'
implementation 'org.datanucleus:datanucleus-core:3.1.3'
implementation 'org.hibernate:hibernate-validator:5.2.4.Final'
implementation 'com.google.api-client:google-api-client:+'
implementation 'com.google.api-client:google-api-client-android:+'
implementation 'com.google.http-client:google-http-client:+'
implementation 'com.google.http-client:google-http-client-android:+'
}
task datanucleusEnhance {
description "Enhance JPA model classes using DataNucleus Enhancer"
dependsOn compileJava
doLast {
// define the entity classes
def entityFiles = fileTree(sourceSets.main.output.classesDir).matching {
include '/*.class'
}
println "Enhancing with DataNucleus the following files"
entityFiles.getFiles().each {
println it
}
// define Ant task for DataNucleus Enhancer
ant.taskdef(
name : 'datanucleusenhancer',
classpath : sourceSets.main.runtimeClasspath.asPath,
// classname : 'org.datanucleus.enhancer.EnhancerTask'
// the below is for DataNucleus Enhancer 3.1.1
classname : 'org.datanucleus.enhancer.tools.EnhancerTask'
)
// run the DataNucleus Enhancer as an Ant task
ant.datanucleusenhancer(
classpath: sourceSets.main.runtimeClasspath.asPath,
verbose: true,
api: "JDO") {
entityFiles.addToAntBuilder(ant, 'fileset', FileCollection.AntType.FileSet)
}
}
}
classes.dependsOn(datanucleusEnhance)
This works as soon as we switch back to Java 7.

"Cannot add a configuration with name 'endpoints' as a configuration..."

I am trying to migrate to GAE framework 2.0. As I follow the document, I realised that when I add this line to build.gradle.
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
I can this error message:
Error:Cannot add a configuration with name 'endpoints' as a
configuration with that name already exists.
Did anyone encounter the same error?
My build.gradle is below:
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:+'
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:+'
}
}
repositories {
mavenCentral()
jcenter()
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.56'
testCompile 'junit:junit:4.12'
testCompile 'com.google.appengine:appengine-testing:1.9.56'
testCompile 'com.google.appengine:appengine-api-stubs:1.9.56'
// 2.0
compile group: 'com.google.endpoints', name: 'endpoints-framework', version: '+'
compile group: 'com.googlecode.junit-toolbox', name: 'junit-toolbox', version: '1.5'
compile 'com.google.appengine:appengine-endpoints:1.9.50'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.50'
compile 'com.googlecode.objectify:objectify:5.1.5'
compile 'org.json:json:20151123'
compile 'javax.servlet:servlet-api:2.5'
compile 'org.apache.httpcomponents:httpclient:4.5.2'
compile 'com.ganyo:gcm-server:1.0.2'
compile 'com.google.appengine.tools:appengine-gcs-client:0.4.4'
//compile 'commons-fileupload:commons-fileupload:1.3.1'
compile 'com.google.apis:google-api-services-storage:v1-rev66-1.21.0'
}
appengine {
downloadSdk = true
appcfg {
oauth2 = true
}
endpoints {
getClientLibsOnBuild = true
getDiscoveryDocsOnBuild = true
}
httpAddress = "0.0.0.0"
}
The appengine plugin you've already applied already creates a configuration named endpoints - see here. Are you sure that both plugins, I mean appengine and com.google.cloud.tools.endpoints-framework-server can be used together in a project? Since there might be only one configuration with particular name.

Resources