Crash app when using AndroidAnnotations with support:appcompat-v7 version 23 + - android

I'm using lastest AndroidAnnotations 4.1.0(link) and try to change appcompat to 24.2.1 to support targetVersion 24. But, My app is crashed when using appcompat-v7 version 23+, however, it runs normally on appcompat-v7:22.2.0. Any suggestion is appriciated. Below is my error logs:
FATAL EXCEPTION: main
Process: ABC, PID: 1275
java.lang.RuntimeException: Unable to start activity ComponentInfo{MyPackage/MyPackage.activities.MainActivity_}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2237)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2286)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:212)
at android.app.ActivityThread.main(ActivityThread.java:5137)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:718)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at MyPackage.activities.MainActivity_.setContentView(MainActivity_.java:51)
at MyPackage.activities.MainActivity_.onCreate(MainActivity_.java:40)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2201)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2286) 
at android.app.ActivityThread.access$800(ActivityThread.java:144) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:212) 
at android.app.ActivityThread.main(ActivityThread.java:5137) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:718) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.IllegalArgumentException: Binary XML file line #7: Must specify unique android:id, android:tag, or have a parent with an id for MyPackage.fragments.MainFragment_
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2387)
at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:120)
at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:376)
at android.support.v4.app.BaseFragmentActivityHoneycomb.onCreateView(BaseFragmentActivityHoneycomb.java:33)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:75)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
at MyPackage.activities.MainActivity_.setContentView(MainActivity_.java:51) 
at MyPackage.activities.MainActivity_.onCreate(MainActivity_.java:40) 
at android.app.Activity.performCreate(Activity.java:5231) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2201) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2286) 
at android.app.ActivityThread.access$800(ActivityThread.java:144) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:212) 
at android.app.ActivityThread.main(ActivityThread.java:5137) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:718) 
at dalvik.system.NativeStart.main(Native Method) 
And this is my gradle
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
...
def PACKAGE_NAME = "MyPackage"
def VERSION_CODE = 1
def VERSION_NAME = "1.0.0"
def AAVersion = '4.1.0'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
buildscript {
repositories {
mavenCentral()
...
}
dependencies {
// replace with the current version of the Android plugin
classpath 'com.android.tools.build:gradle:2.2.0'
// replace with the current version of the android-apt plugin
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
...
}
}
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
resourcePackageName PACKAGE_NAME
}
}
repositories {
mavenCentral()
...
}
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId PACKAGE_NAME
minSdkVersion 14
targetSdkVersion 24
versionCode VERSION_CODE
versionName VERSION_NAME
// Enabling multidex support.
multiDexEnabled true
}
signingConfigs {
...
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
...
}
dexOptions {
...
}
...
}
dependencies {
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
...
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.google.android.gms:play-services-maps:9.6.1'
compile 'com.google.android.gms:play-services-location:9.6.1'
compile 'com.google.android.gms:play-services-gcm:9.6.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.retrofit2:converter-jackson:2.1.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0'
compile('com.squareup.okhttp3:okhttp:3.2.0') {
exclude module: 'okhttp'
}
compile 'io.reactivex:rxandroid:1.0.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
compile 'com.github.mrmike:ok2curl:0.2.3'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.android.support:multidex:1.0.1'
compile('com.crashlytics.sdk.android:crashlytics:2.6.2#aar') {
transitive = true;
}
}
repositories {
flatDir {
dirs 'libs'
}
}

As it is an be ready from the stack trace, the problem is that you did not add any ID neither a tag for your Fragment in the xml layout where you declare an instance if it. The Fragment in question is MyPackage.fragments.MainFragment_. This is a standard error, not related to AndroidAnnotations.
<fragment android:name="MyPackage.fragments.MainFragment_"
android:id="#+id/fragment_id" <!-- Add an ID -->
android:layout_width="match_parent"
android:layout_height="match_parent" />

Related

java.lang.NoSuchMethodError: when using realm database, no method found

I have included Realm in a project, and have followed the documentation. But whenever I compile and run the app, i get the following error:
FATAL EXCEPTION: main
Process: org.innoversetech.wifinity, PID: 8391
java.lang.NoSuchMethodError: No static method loadLibrary(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V in class Lcom/getkeepsafe/relinker/ReLinker; or its super classes (declaration of 'com.getkeepsafe.relinker.ReLinker' appears in /data/app/org.innoversetech.wifinity-2/split_lib_dependencies_apk.apk:classes16.dex)
at io.realm.internal.RealmCore.loadLibrary(RealmCore.java:60)
at io.realm.Realm.init(Realm.java:200)
at org.innoversetech.wifinity.MyApplication.onCreate(MyApplication.java:17)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1037)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6496)
at android.app.ActivityThread.access$1800(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
I have been at this for hours now and I cannot understand what the problem is. Here is my code for MyApplication class:
import android.app.Application;
import io.realm.Realm;
import io.realm.RealmConfiguration;
public class MyApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
Realm.init(getApplicationContext());
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder()
.name(Realm.DEFAULT_REALM_NAME)
.schemaVersion(0)
.deleteRealmIfMigrationNeeded()
.build();
Realm.setDefaultConfiguration(realmConfiguration);
}
}
This is my build.gradle for app level:
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
repositories {
maven {
url "https://jitpack.io"
}
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "org.innoversetech.wifinity"
minSdkVersion 18
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
proguardFile 'D:/Code/Android/KillMe/Wifinity/app/proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//dependencies
compile('com.mikepenz:materialdrawer:5.9.5#aar') {
transitive = true
}
compile 'devlight.io:navigationtabbar:1.2.5'
compile 'devlight.io:navigationtabbar:1.2.5'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-vector-drawable:25.3.1'
compile 'com.github.florent37:materialviewpager:1.2.1'
compile 'com.flaviofaria:kenburnsview:1.0.7'
compile 'com.jpardogo.materialtabstrip:library:1.1.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.jakewharton:butterknife:8.6.0'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.mani:ThinDownloadManager:1.3.0'
compile 'com.github.barteksc:android-pdf-viewer:2.6.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.afollestad.material-dialogs:core:0.9.4.5'
compile 'com.afollestad.material-dialogs:commons:0.9.4.5'
compile 'com.felipecsl.asymmetricgridview:library:2.0.1'
compile 'com.race604.waveloading:library:1.1.1'
compile 'com.github.Yalantis:GuillotineMenu-Android:1.2'
compile 'net.steamcrafted:materialiconlib:1.1.3'
compile 'com.mikepenz:google-material-typeface:+#aar'
compile 'com.mikepenz:fontawesome-typeface:+#aar'
compile 'com.diegodobelo.expandingview:expanding-view:0.9.4'
compile 'com.github.thorbenprimke:realm-recyclerview:0.9.25'
compile 'it.sephiroth.android.library.targettooltip:target-tooltip-library:1.3.15'
compile 'com.getkeepsafe.relinker:relinker:1.2.2'
compile 'com.github.KeepSafe:ReLinker:1.1'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '26.0.0-alpha1'
}
}
}
}
And this is the project level gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven{
url "https://jitpack.io"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath "io.realm:realm-gradle-plugin:3.5.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is the error I get when I remove the ReLinker libraries:
Process: org.innoversetech.wifinity, PID: 22788
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/getkeepsafe/relinker/ReLinker;
at io.realm.internal.RealmCore.loadLibrary(RealmCore.java:60)
at io.realm.Realm.init(Realm.java:200)
at org.innoversetech.wifinity.MyApplication.onCreate(MyApplication.java:17)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1037)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6496)
at android.app.ActivityThread.access$1800(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.getkeepsafe.relinker.ReLinker" on path: DexPathList[[zip file "/data/app/org.innoversetech.wifinity-1/base.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_dependencies_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_0_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_1_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_2_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_3_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_4_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_5_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_6_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_7_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_8_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/org.innoversetech.wifinity-1/lib/arm, /data/app/org.innoversetech.wifinity-1/base.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_dependencies_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_0_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_1_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_2_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_3_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_4_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_5_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_6_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_7_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_8_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_9_apk.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at io.realm.internal.RealmCore.loadLibrary(RealmCore.java:60) 
at io.realm.Realm.init(Realm.java:200) 
at org.innoversetech.wifinity.MyApplication.onCreate(MyApplication.java:17) 
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1037) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6496) 
at android.app.ActivityThread.access$1800(ActivityThread.java:229) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:7406) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
Suppressed: java.lang.ClassNotFoundException: com.getkeepsafe.relinker.ReLinker
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 14 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
Realm depends on implementation 'com.getkeepsafe.relinker:relinker:1.2.2' (basically "compile"), but I think your issue is caused by
compile 'com.github.thorbenprimke:realm-recyclerview:0.9.25'
Because version 0.9.25 brings in Realm version 2.2.1, so that can clash against Realm 3.5.0.
A possible solution would be to copy the sources of RealmBasedRecyclerViewAdapter to your code so that it doesn't depend on old things.
Another thing you can do is just not use RealmBasedRecyclerViewAdapter, and give a try for RealmRecyclerViewAdapter in realm-android-adapters.
A clean+rebuild might also help.
in your onCreate use,
realmConfiguration = new RealmConfiguration.Builder().build();
realm = Realm.getInstance(realmConfiguration);

Didn't find class "com.example.App" on path: DexPathList

I have this strange error I do not know how to resolve. I test my App in my phone samsung j5 (Marshmellow) and it's working ok. But now i'm testing it in samsung j3 (lollipop) the app crash as startup and the error is this one:
10-02 22:28:59.426 4395-4395/com.example.sony.snapcamera E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.sony.snapcamera, PID: 4395
java.lang.RuntimeException: Unable to instantiate application com.example.sony.snapcamera.App: java.lang.ClassNotFoundException: Didn't find class "com.example.sony.snapcamera.App" on path: DexPathList[[zip file "/data/app/com.example.sony.snapcamera-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.sony.snapcamera-1/lib/arm, /vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:661)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6002)
at android.app.ActivityThread.access$1700(ActivityThread.java:218)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6934)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.sony.snapcamera.App" on path: DexPathList[[zip file "/data/app/com.example.sony.snapcamera-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.sony.snapcamera-1/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newApplication(Instrumentation.java:1003)
at android.app.LoadedApk.makeApplication(LoadedApk.java:651)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6002) 
at android.app.ActivityThread.access$1700(ActivityThread.java:218) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:6934) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) 
Suppressed: java.lang.NoClassDefFoundError: com.example.sony.snapcamera.App
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:226)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
at dalvik.system.DexPathList.findClass(DexPathList.java:321)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
... 14 more
Suppressed: java.lang.ClassNotFoundException: com.example.sony.snapcamera.App
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
This is my AndroidManifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sony.snapcamera">
.....
<application
android:name="com.example.sony.snapcamera.App"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#mipmap/App_icon"
android:label="#string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="#style/AppTheme"
>
...
This is my App class :
package com.example.sony.snapcamera;
import android.app.Application;
import android.content.Context;
import com.adobe.creativesdk.foundation.AdobeCSDKFoundation;
import com.adobe.creativesdk.foundation.auth.IAdobeAuthClientCredentials;
import com.bumptech.glide.request.target.ViewTarget;
public class App extends Application implements IAdobeAuthClientCredentials {
/* Be sure to fill in the two strings below. */
private static final String CREATIVE_SDK_CLIENT_ID = "";
private static final String CREATIVE_SDK_CLIENT_SECRET = "";
private static final String CREATIVE_SDK_REDIRECT_URI = "";
private static final String[] CREATIVE_SDK_SCOPES = {"email", "profile", "address"};
#Override
public void onCreate() {
super.onCreate();
ViewTarget.setTagId(R.id.glide_tag);
AdobeCSDKFoundation.initializeCSDKFoundation(getApplicationContext());
}
#Override
public String getClientID() {
return CREATIVE_SDK_CLIENT_ID;
}
#Override
public String getClientSecret() {
return CREATIVE_SDK_CLIENT_SECRET;
}
#Override
public String[] getAdditionalScopesList() {
return CREATIVE_SDK_SCOPES;
}
#Override
public String getRedirectURI() {
return CREATIVE_SDK_REDIRECT_URI;
}
}
Here it is my app gradle :
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'
}
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.sony.snapcamera"
minSdkVersion 21
targetSdkVersion 25
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [appPackageName: "${applicationId}"]
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/DEPENDENCIES'
pickFirst 'AndroidManifest.xml'
}
dexOptions {
jumboMode true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.github.XunMengWinter:CircularAnim:0.3.4'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.zomato:androidphotofilters:1.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:design:25.3.1'
compile 'com.github.chrisbanes:PhotoView:1.3.1'
compile 'com.writingminds:FFmpegAndroid:0.3.2'
compile 'com.google.firebase:firebase-database:11.4.0'
compile 'com.google.android.gms:play-services:11.4.0'
compile 'com.google.maps.android:android-maps-utils:0.4.3'
compile 'com.firebaseui:firebase-ui:0.4.0'
compile 'com.google.firebase:firebase-auth:11.4.0'
compile 'com.google.firebase:firebase-crash:11.4.0'
compile 'com.google.code.gson:gson:2.8.1'
// compile 'com.firebase:geofire-android:2.1.1'
compile 'com.algolia:algoliasearch-android:3.10.1'
// compile 'com.android.support:cardview-v7:25.1.1'
/* Add the CSDK framework dependencies (Make sure these version numbers are correct) */
compile 'com.adobe.creativesdk.foundation:auth:0.9.1251'
compile 'com.adobe.creativesdk:image:4.8.4'
compile 'com.localytics.android:library:3.8.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
I already tested to clean and rebuild project, I also tested to disable instant run but nothing worked for me, I can't even realise the problem because it works very good in j5 and it crash in j3, Please help.
enable multidex,
1. Add following dependency in app gradle file compile
'com.android.support:multidex:1.0.1' and
defaultConfig {
multiDexEnabled true
}
2. Your application class need to extends MultiDexApplication

The following classes could not be instantiated:- android.support.design.widget.NavigationView

I'm trying to use this https://github.com/Siclo-Mobile/EZPhotoPicker in my app.
I had my build.gradle (inside "app" folder) looking like this before the implementation (And the app working fine):
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
signingConfigs {
vitalRelease {
keyAlias 'XXXX'
keyPassword 'XXXXX'
storeFile file('XXXXXXXXXXX')
storePassword 'XXXXXXX'
}
}
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.enye.cme"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// The Fabric Gradle plugin uses an open ended version to react
// quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.code.gson:gson:1.7.2'
compile 'com.splitwise:tokenautocomplete:2.0.2#aar'
compile 'com.github.citux:datetimepicker:0.2.0'
compile 'com.prolificinteractive:material-calendarview:1.1.0'
//compile 'com.nbsp:library:1.08'
compile 'com.github.siyamed:android-shape-imageview:0.9.+#aar'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.joanzapata.pdfview:android-pdfview:1.0.4#aar'
compile 'com.google.android.gms:play-services-ads:9.0.0'
compile('com.crashlytics.sdk.android:answers:1.3.6#aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics:2.6.2#aar') {
transitive = true;
}
compile 'com.nononsenseapps:filepicker:2.5.2'
compile 'com.google.firebase:firebase-core:9.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'com.google.android.gms:play-services-appindexing:9.0.0'
}
apply plugin: 'com.google.gms.google-services'
I followed the instructions given there in the README.md in the GitHub, and now my build.gradle looks like this:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://dl.bintray.com/siclo/SicloAndroidOSS' } //ADDED THIS LINE
}
android {
signingConfigs {
vitalRelease {
keyAlias 'XXXXX'
keyPassword 'XXXXXX'
storeFile file('XXXXXXXXXXX')
storePassword 'XXXXXX'
}
}
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.enye.cme"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.vitalRelease
}
}
productFlavors {
vital {
applicationId "com.enye.mce"
buildConfigField 'String', 'appId', '"MCE"';
}
cuidam {
applicationId "com.enye.cuidam"
buildConfigField 'String', 'appId', '"CUIDAM"';
}
}
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// The Fabric Gradle plugin uses an open ended version to react
// quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.code.gson:gson:1.7.2'
compile 'com.splitwise:tokenautocomplete:2.0.2#aar'
compile 'com.github.citux:datetimepicker:0.2.0'
compile 'com.prolificinteractive:material-calendarview:1.1.0'
//compile 'com.nbsp:library:1.08'
compile 'com.github.siyamed:android-shape-imageview:0.9.+#aar'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.joanzapata.pdfview:android-pdfview:1.0.4#aar'
compile 'com.google.android.gms:play-services-ads:9.0.0'
compile('com.crashlytics.sdk.android:answers:1.3.6#aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics:2.6.2#aar') {
transitive = true;
}
compile 'com.nononsenseapps:filepicker:2.5.2'
compile 'com.google.firebase:firebase-core:9.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'com.google.android.gms:play-services-appindexing:9.0.0'
compile 'com.siclo.ezphotopick:library:1.0.1' //ADDED THIS LINE
}
apply plugin: 'com.google.gms.google-services'
As you can see, I didn't change anything but those 2 lines that are given in the instructions.
Now when I start the app it crashes and throws me this error:
01-18 18:51:22.096 9036-9036/com.enye.cuidam E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.enye.cuidam, PID: 9036
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.enye.cuidam/com.enye.cme.activities.MainActivity}: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class android.support.design.widget.NavigationView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2426)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class android.support.design.widget.NavigationView
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.enye.cme.activities.MainActivity.onCreate(MainActivity.java:117)
at android.app.Activity.performCreate(Activity.java:6245)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class android.support.design.widget.NavigationView
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.enye.cme.activities.MainActivity.onCreate(MainActivity.java:117)
at android.app.Activity.performCreate(Activity.java:6245)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.enye.cme.activities.MainActivity.onCreate(MainActivity.java:117)
at android.app.Activity.performCreate(Activity.java:6245)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: java.lang.NoClassDefFoundError: android.support.design.internal.NavigationMenuPresenter
at android.support.design.widget.NavigationView.<init>(NavigationView.java:80)
at android.support.design.widget.NavigationView.<init>(NavigationView.java:92)
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.enye.cme.activities.MainActivity.onCreate(MainActivity.java:117)
at android.app.Activity.performCreate(Activity.java:6245)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
The #117 line of MainActivity is this one:
setContentView(R.layout.activity_main);
And this is the layout activity_main:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:id="#+id/drawer_layout"
android:layout_width="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true" tools:openDrawer="start">
<include layout="#layout/app_bar_main" android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView android:id="#+id/nav_view"
android:layout_width="wrap_content" android:layout_height="match_parent"
android:layout_gravity="start" android:fitsSystemWindows="true"
app:menu="#menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
Am I doing something wrong? It doesn't even inflate the activity, I guess I messed up the build.gradle.
Thanks in advance for your help!

Why is Firebase causing the app to crash

Project Gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.myapp"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
//compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.google.android.gms:play-services:9.8.0'
compile 'com.google.firebase:firebase-core:9.8.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Activity:
private DatabaseReference mDatabase;
...
mDatabase = FirebaseDatabase.getInstance().getReference(Config.FIREBASE_URL); //public static final String FIREBASE_URL = "https://myapp.firebaseio.com/ ";
...
mDatabase.setValue(edittextName.getText().toString());
Class:
public class Config {
public static final String FIREBASE_URL = "https://myapps.firebaseio.com/ ";
}
I am getting the following error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp, PID: 30211
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp/com.myapp.MainActivity}: com.google.firebase.database.DatabaseException: Failed to get FirebaseDatabase instance: FirebaseApp object has no DatabaseURL in its FirebaseOptions object.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2316)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2376)
at android.app.ActivityThread.access$800(ActivityThread.java:147)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5253)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: com.google.firebase.database.DatabaseException: Failed to get FirebaseDatabase instance: FirebaseApp object has no DatabaseURL in its FirebaseOptions object.
at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
at com.myapp.MainActivity.onCreate(MainActivity.java:103)
at android.app.Activity.performCreate(Activity.java:5975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2376) 
at android.app.ActivityThread.access$800(ActivityThread.java:147) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5253) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
How can I resolve the issue.
The link provided does not resolve my issue!
Per #qbix, I had to use getReferenceFromUrl() and the app didn't crash.

Kotlin collections throw ClassNotFoundException on Android

Using any of the lines below throws a ClassNotFoundException when app is run on Android.
val list = listOf("a", "b")
val arrayList = arrayListOf("a", "b")
val map = mapOf("key" to "value")
The exception:
04-28 15:12:00.770 27326-27326/com.example.kotlin E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.kotlin, PID: 27326
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/collections/CollectionsKt;
at com.example.kotlin.MainActivity.onCreate(MainActivity.kt:17)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "kotlin.collections.CollectionsKt" on path: DexPathList[[zip file "/data/app/com.example.kotlin-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.kotlin-1/lib/x86, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.example.kotlin.MainActivity.onCreate(MainActivity.kt:17) 
at android.app.Activity.performCreate(Activity.java:6237) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Suppressed: java.lang.ClassNotFoundException: kotlin.collections.CollectionsKt
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 14 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
The following is my app module gradle file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 23
buildToolsVersion "24.0.0 rc3"
defaultConfig {
applicationId "com.example.kotlin"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:gridlayout-v7:23.3.0'
compile 'com.android.support:cardview-v7:23.3.0'
kapt 'com.android.databinding:compiler:2.1.0-beta3'
}
buildscript {
ext.kotlin_version = '1.0.1-2'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
repositories {
mavenCentral()
}
kapt {
generateStubs = true
}
Is there any other dependency I need to add to gradle in order to use any of the Kotlin collection classes?
You need to depend on the Kotlin standard library which contains these classes:
dependencies {
/* ... */
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

Categories

Resources