My app crashes on Backendless.initapp on this line:
Backendless.initApp(this, "8B896105-6244-894C-FF80-9C8045E66600", "D07AC071-C614-2A0D-FF05-E36C6C98B700");
I am using instantApp features and my features Gradle Module looks like so:
apply plugin: 'com.android.feature'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
}
}
lintOptions {
disable 'InvalidPackage', 'RtlCompat'
abortOnError false
}
defaultConfig {
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "3g" //specify the heap size for the dex process
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation group: 'com.backendless', name: 'backendless', version: '5.0.0'
// required for real-time database and real-time messaging
implementation ('io.socket:socket.io-client:1.0.0') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}
implementation project(':base')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
I can confirm that I do have the Backendless SDK installed. I am suspecting that it could be a targeting version issue as the sample targets SDK version 26.
Here is the crash log:
Caused by: java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException
at android.os.Parcel.readException(Parcel.java:1607)
at android.os.Parcel.readException(Parcel.java:1552)
at com.google.android.instantapps.supervisor.ipc.base.MethodInvocationProxy.readReply(PG:2)
at com.google.android.instantapps.supervisor.ipc.base.MethodInvocationProxy.invoke(PG:17)
at java.lang.reflect.Proxy.invoke(Proxy.java:393)
at $Proxy37.startService(Unknown Source)
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1245)
at android.app.ContextImpl.startService(ContextImpl.java:1227)
at android.content.ContextWrapper.startService(ContextWrapper.java:581)
at com.backendless.Backendless.initApp(Backendless.java:196)
at com.theswazi.hobbyist.feature.RegisterActivity.onCreate(RegisterActivity.java:38)
at android.app.Activity.performCreate(Activity.java:6309)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2530)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1499)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5771)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
I ran App without Instant Run and it no longer crashes at Backendless.initApp.
Edit
It seems that the error occurs with Android version 6 but since I only had one device with version 6 I am not entirely sure. I did try another device with Android version 5.1.1 which worked.
Related
I use lint to check an Android app project:
gradlew lint
It shows the following:
> Task :app:compileOfficialDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
The process generates two files: lint-results.html and lint-results.xml. I checked both files, but could not find any information related to deprecated API. Is it possible to generate more details about deprecated API in these two files?
Here's an example "build.gradle" I marked up:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
multiDexEnabled true
applicationId "com.boxpik.android"
minSdkVersion 17
targetSdkVersion 19
...
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:all"
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
...
In this example, I added options.compilerArgs << "-Xlint:all" to build.gradle.
This gave me a bunch of Lint warning in my Android Studio "Build" window:
^
C:\xyz\PoolToScoreDetailFragment.java:55: warning: [deprecation] ProgressDialog in android.app has been deprecated
private ProgressDialog pDialog;
^
C:\xyz\PoolToScoreDetailFragment.java:346: warning: [deprecation] ProgressDialog in android.app has been deprecated
pDialog = new ProgressDialog(application);
I am getting a DuplicateFileException while building Apk. I used the Applogic source code from GitHub to develop a chat app and while building the gradle I got this exception not able to build the apk. I am using Android Studio 3.0 Gradle version 3.3 and Android Plugin version 2.3.3 Build tool version 26.0.2 sdk version API26
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.mobicomkit.sample"
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ECLIPSE_.SF'
exclude 'META-INF/ECLIPSE_.RSA'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':mobicomkitui') //Note: use this for customization
compile 'com.applozic.communication.uiwidget:mobicomkitui:5.2'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:cardview-v7:26.0'
compile 'com.android.support:recyclerview-v7:26.0'
compile('com.crashlytics.sdk.android:crashlytics:2.5.7#aar') {
transitive = true;
}
}
apply plugin: 'com.google.gms.google-services'enter image description here
You cant use the both at a time gradle dependency and imported applozic source code and any one you need to use
Use this in your case you imported source code
compile project(':mobicomkitui') //Note: use this for customization
Remove this code from your app build.gradle file
compile 'com.applozic.communication.uiwidget:mobicomkitui:5.2'
I migrated source code from Eclipse to Android studio, when I build the project in android studio, I got the following failure.
FAILURE: Build failed with an exception.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/print/PrintHelper$1.class
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile (project(':facebook')){
exclude group: 'com.android.support', module: 'multidex'
}
compile project(':libraryBasePera')
compile project(':google-play-services_lib')
compile 'com.android.support:multidex:1.0.1'
}
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
I tried many ways (exclude module support-v4, deleted support-v4 jar, clean, rebuild project...) but I am still stuck here. Can any one help me to figure out the problem?
Thank you very much.
Try to check lib folder. I had same error because I have added support-v4 jar in my lib folder by mistake.
My app works fine. Once I add "compile 'com.github.paolorotolo:appintro:3.3.0'" to my dependencies to include this library, this error occurs:
Error inflating class android.support.design.widget.NavigationView
Here is my complete build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.myId"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0#aar'
compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0#aar'
compile 'com.nhaarman.listviewanimations:lib-core-slh:3.1.0#aar'
compile 'com.github.paolorotolo:appintro:3.3.0' #This line makes it crash
}
Finally I found out that I had to change
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
to
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
The reason may be in styles. Try to use in Manifest
<activity android:name=".IntroActivity" ndroid:theme="#style/FullscreenTheme"/>
and in styles.xml :
<style name="FullscreenTheme" parent="Theme.AppCompat.Light.NoActionBar"/>
So I finally managed to get my android studio to run JUnit test that's integrated with robolectric so I can do http calls and other things without running it on device or emulator. Followed the structure from here which worked wonders: https://github.com/robolectric/deckard-gradle
Now, I managed to run it fine on AndroidStudio, however I want to setup a cron so it can be run automatically, and when executing the test by command line via gradle I am getting "java.lang.UnsatisfiedLinkError: no pjsua in java.library.path". Note that our code uses a pjsip lib code that we compile separately, and we put the .so file in the jniLibs folder. I have another jUnit test that's really simple, and that one works fine whether through gradle command line or AndroidStudio.
The gradle command I followed from http://tools.android.com/tech-docs/unit-testing-support which are either:
1) ./gradlew test --continue
or
2) ./gradlew test -Dtest.single=Test.java
This is what our gradle file looks like for the app layer:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.foo.test"
minSdkVersion 14
targetSdkVersion 21
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
moduleName "libpjsua"
}
}
sourceSets {
main {
jni.srcDirs = []
}
}
signingConfigs {
// hidden
}
buildTypes {
release {
signingConfig signingConfigs.release
}
debug {
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:21.0.3'
compile files('libs/android-logging-log4j-1.0.3.jar')
compile files('libs/libphonenumber-6.2.jar')
compile files('libs/log4j-1.2.17.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/ostermillerutils_1_07_00.jar')
// dependencies to do automation testing
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-core:1.1'
testCompile 'org.hamcrest:hamcrest-library:1.1'
testCompile 'org.hamcrest:hamcrest-integration:1.1'
testCompile('org.robolectric:robolectric:2.4') {
exclude module: 'classworlds'
exclude module: 'commons-logging'
exclude module: 'httpclient'
exclude module: 'maven-artifact'
exclude module: 'maven-artifact-manager'
exclude module: 'maven-error-diagnostics'
exclude module: 'maven-model'
exclude module: 'maven-project'
exclude module: 'maven-settings'
exclude module: 'plexus-container-default'
exclude module: 'plexus-interpolation'
exclude module: 'plexus-utils'
exclude module: 'wagon-file'
exclude module: 'wagon-http-lightweight'
exclude module: 'wagon-provider-api'
}
}
Does anyone have any idea? Many thanks in advance, been at this for a couple of days now.