Program Club

새 Firebase로 업데이트 한 후 예외 java.lang.NoClassDefFoundError : com.google.firebase.FirebaseOptions 발생

proclub 2020. 11. 2. 20:07
반응형

새 Firebase로 업데이트 한 후 예외 java.lang.NoClassDefFoundError : com.google.firebase.FirebaseOptions 발생


나는 사용하여 새 중포 기지 내 응용 프로그램을 업데이트 한 이를 하고 난 내 프로젝트를 컴파일 할 때 지금은 다음과 같은 예외를 얻을.

logcat 은 다음과 같습니다 .

11:57:54.533 27844-27844/com.example.dayshift_2.traveyy E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.dayshift_2.traveyy, PID: 27844
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:1591)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1562)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:4871)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4466)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4406)
at android.app.ActivityThread.access$1500(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1270)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5102)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)

Build.gradle :

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
    applicationId "com.example.dayshift_2.traveyy"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}
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'])
testCompile 'junit:junit:4.12'

compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.firebase:firebase-database:9.0.0'
compile 'com.google.firebase:firebase-auth:9.0.0'
compile 'com.android.support:support-v13:23.3.0'
compile 'com.roughike:bottom-bar:1.2.1'
}


apply plugin: 'com.google.gms.google-services'

이 예외가 어디서 발생하는지 잘 모르겠습니다. 어떤 도움이라도 대단히 감사하겠습니다. 감사합니다


이것은 나를 위해 일했습니다.

  1. 아직 업데이트하지 않았다면 Android SDK Manager> Extras에서 'Google Play 서비스'를 개정 30으로 업데이트하십시오.

Android SDK Manager > Extras > Google Play Services

  1. 그런 다음 compile 'com.android.support:multidex:1.0.1'종속성에 추가하십시오 (또는 multiDexEnabled true필요하지 않은 경우 간단히 제거하십시오 )

  2. 이 속성을 매니페스트의 애플리케이션 태그에 추가합니다. android:name="android.support.multidex.MultiDexApplication"
    Android 매니페스트에 이미 사용자 정의 애플리케이션 클래스가 정의되어있는 경우 MultiDexApplication대신 다음에서 확장합니다.Application

도움이 되었기를 바랍니다.


최신 Google Play 서비스를 사용하고 있지만 작동하지 않았습니다. 나를 위해이 절차는 효과가 있습니다.

  1. 내 애플리케이션 클래스 업데이트 :

    public class App extends Application {
      @Override
      protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
     }
    }
    
  2. 업데이트 된 build.gradle파일 :

    defaultConfig {
        ...
        multiDexEnabled true
    }
    
  3. 포함 된 종속성 :

    dependencies {
      compile 'com.android.support:multidex:1.0.0'
    }
    

프로젝트에서 플레이어 서비스와 파이어베이스를 모두 사용하는 경우 Google에서 사용 가능한 모든 서비스를 가져 오지 않았는지 확인하고 실제로 필요한 API를 가져 오기만하면됩니다. 예를 들면 :

 compile 'com.google.firebase:firebase-messaging:9.2.0'
 compile 'com.google.android.gms:play-services:9.2.0'

이 방법을 사용하면 noclassdeffounderror가 발생할 수 있습니다 .

플레이 서비스를 제거하고 프로젝트를 동기화하십시오. 앱에서 광고 또는지도 사용과 같은 종속성이있는 경우 특정 API를 정의하십시오. 처럼:

compile 'com.google.android.gms:play-services-maps:9.2.0'

참고 : Maximum은 multiDexEnabled true 를 사용하지 마십시오 . 이것이 문제를 해결하는 마지막 단계입니다.

이것이 도움이되기를 바랍니다.


나는 다운 그레이드 에서 내 구글 플레이 서비스 종속성을

compile 'com.google.android.gms:play-services:9.2.0' 

...에

compile 'com.google.android.gms:play-services:8.4.0' 

나를 위해이 문제를 해결했습니다.

자세한 설명은 다음 스택 오버플로 링크를 참조하십시오 .


참고 : 최신 Google Play 서비스로 업그레이드하면
compile 'com.google.android.gms:play-services:9.4.0'이 문제도 해결되었습니다.

또는 모든 Google Play 서비스를 가져 오는 대신 필요한 특정 서비스를 선택적으로 가져올 수 있습니다.


1 단계 : multidex 수정

애플리케이션 클래스 :

public class StudyNApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        MultiDex.install(this);
    }
 }

성적 파일

defaultConfig { 
...
multiDexEnabled true
}

dependencies {
  compile 'com.android.support:multidex:1.0.0'
}

2 단계 : java.lang.NoClassDefFoundError : com.google.firebase.FirebaseOptions 수정

풀다

compile 'com.google.android.gms:play-services:9.4.0'

두 개의 lib를 추가하십시오.

compile 'com.google.android.gms:play-services-maps:9.4.0'
compile 'com.google.android.gms:play-services-location:9.4.0'

잘 작동했습니다.


잊지 마세요.

android:name="android.support.multidex.MultiDexApplication"

나는 이것을 추가하고 플레이 서비스 의존성을 8.4.0으로 낮추어 'com.google.android.gms : play-services : 8.4.0'을 컴파일하여 해결했습니다.

    @Override
protected void attachBaseContext(Context newBase) {
    super.attachBaseContext(newBase);
    MultiDex.install(this);
}

매니페스트에 다음을 추가하십시오.

android:name="android.support.multidex.MultiDexApplication"

targetSDKVersion을 22에서 23으로 늘 렸을 때 동일한 오류가 발생했습니다. 문제를 해결하기 위해 최소 하루를 보냈습니다. 이제 마지막으로 build.gradle 파일에서 다른 플레이 서비스 API를 사용하는 결과를 찾습니다. Source : https://developers.google.com/android/guides/setup#add_google_play_services_to_your_project

관련 API 만 추가했는데 내 앱이 제대로 작동합니다.


나는이 답변 에서이 문제에 대한 해결책을 찾았다 고 생각 합니다. 한 번 살펴보고 @Gabriele Mariotti 에게 감사드립니다 .

최상위 build.gradle에 다음을 추가해야합니다.

buildscript {
    // ...
    dependencies {
        // ...
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

그런 다음 모듈 build.gradle에서 :

apply plugin: 'com.android.application'

android {
  // ...
}

dependencies {
  // ... 

}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

 GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(**R.string.default_web_client_id**))
            .requestEmail()
            .build();

In my same case i changed requestIdToken and it worked.


dependencies {
compile 'com.android.support:support-v4:25.0.1'
compile 'com.google.firebase:firebase-ads:9.0.2'
compile files('libs/StartAppInApp-3.5.0.jar')
compile 'com.android.support:multidex:1.0.1'    
}  

apply plugin: 'com.google.gms.google-services'.


try to solve...

in Gradle file

multiDexEnabled true

compile 'com.android.support:multidex:1.0.1'

Manifest file

application tag add this line

android:name="android.support.multidex.MultiDexApplication"


Configure your app for multidex to resolve this issue.

For minSdkVersion 21 or above set multiDexEnabled to true in your module-level build.gradle file, as shown below:

android {
  defaultConfig {
    //...
    minSdkVersion 21 
    targetSdkVersion 26
    multiDexEnabled true
   }
  //...
 }

For minSdkVersion API 20 or lower

  1. Modify the module-level build.gradle and add the multidex library as a dependency, as shown below:

    android { defaultConfig { ... minSdkVersion 15 targetSdkVersion 26 multiDexEnabled true } //... } dependencies { compile 'com.android.support:multidex:1.0.1' }

  2. If you do not override the Application class, edit your manifest file to set android:name in the application tag as follows

    <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.myapp"> <application android:name="android.support.multidex.MultiDexApplication"> //... </application> </manifest>

    2.1.1. If you do override the Application class Extend MultiDexApplication

    public class MyApplication extends MultiDexApplication { //... }
    

    2.1.2. Or if you do override the Application class but it's not possible to change the base class, then you can instead override the attachBaseContext() method and call MultiDex.install(this) to enable multidex:

    public class MyApplication extends SomeOtherApplication { @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } }

for more mdex-gradle

Hope this will be help others who are facing same issue.


Before doing all those hectic solutions, try to Clean Project or Rebuild Project from Android Studio.

java.lang. NoClassDefFoundError

Exceptions is thrown when you change any Class name in your project but it couldn't get the changes you made in Runtime.


Downgrade your dependency in build.gradle file:

from:

compile 'com.google.android.gms:play-services:9.4.0'

to:

compile 'com.google.android.gms:play-services:7.3.0'

This worked in my case, hope same for you.

참고URL : https://stackoverflow.com/questions/37360126/getting-exception-java-lang-noclassdeffounderror-com-google-firebase-firebaseop

반응형