When i run my codes Adroid studio gives that error
my gradle file like under below and Android Studio v2.2 gradle is 'com.android.tools.build:gradle:2.2.0-alpha1'
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
defaultConfig {
applicationId "com.asd.asd"
minSdkVersion 14
targetSdkVersion 23
versionCode 9
versionName "1.3.4"
multiDexEnabled true
}
buildTypes {
release {
debuggable false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dexOptions {
javaMaxHeapSize "4g"
jumboMode true
preDexLibraries false
}
}
dependencies {
compile project(':mPChartLib')
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.code.gson:gson:2.3.1'
compile files('libs/commons-httpclient-3.1.jar')
compile files('libs/signpost-commonshttp4-1.2.1.2.jar')
compile files('libs/signpost-core-1.2.1.2.jar')
compile files('libs/pushwoosh-4.0.4.jar')
compile files('libs/httpcore-4.4.4.jar')
compile files('libs/httpclient-4.5.2.jar')
compile 'com.google.android.gms:play-services:9.0.0'
}
05-30 20:41:50.785 14551-14551/com.asd.asd/AndroidRuntime: FATAL EXCEPTION: main Process: com.asd.asd, PID: 14551
java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions
at com.google.firebase.FirebaseApp.zzbu(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1638)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1609)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5008)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4582)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4522)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
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:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
idont use any firebase application but i got this error. so i try somany tecnique which are found on internet . but noting change .
can you help me pls
first update your Google Repository
in your sdk
second enable multidex
like
defaultConfig {
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
compile with
compile 'com.android.support:multidex:1.0.1'
classpath 'com.google.gms:google-services:3.0.0'
This bug is reported with newer versions mostly arround Revision 28,29 and its resolved in newer Play services versions so very first if you having this issue then make sure you have updated version of Google Play service in your Android studio.
Follow these steps:
- Go to Android SDK Manager
- Go to Extra
And update it to version 30 or later.
Then if you are using MultiDex in your Application then please use it only if it's compulsory.
Make sure you have follow these steps when integrating MultiDex.
In you App level Build.Gradle
defaultConfig {
applicationId "com.reversebits.tapanhp.saffer"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
Apply MultiDex dependency in dependencies
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
wearApp project(':wear')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.android.support:multidex:1.0.1'
}
Then inside your AndroidMenifest.xml file make sure that Application tag have name of MultiDexApplication.
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
Note
if you have custom Application class and using it in your menifest file then you can initialize multidex in your Application class as follows,
public class AppClass extends Application {
private static Context context;
private static AppClass mInstance;
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
In your top-level build.gradle you have to add:
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.0.0'
}
}
Then in your module build.gradle
:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
1, Open your SDK Manager then install Google Play Services (rev 30) and Google Repository (rev 26).
2, Add classpath 'com.google.gms:google-services:3.0.0'
to your build.gradle of project.
You should include Multidex library to your gradle.build
compile 'com.android.support:multidex:1.0.1'
And as suggested by @Lollipop you need to download Google play Services and add classpath in your project. Since Firebase need this library to work properly.
EDIT
buildscript
{
dependencies
{
classpath 'com.google.gms:google-services:3.0.0'
}
}
来源:https://stackoverflow.com/questions/37535141/android-noclassdeffounderror-com-google-firebase-firebaseoptions