티스토리 뷰
안드로이드
[안드로이드]java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions 오류
머어하지 2017. 5. 25. 22:18이 오류에 앞서 다음과 같은 Method 초과로 인한 문제로 발생한 다음의 오류에서도 같은 방법을 적용할 수 있습니다.
1 2 | Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536 | cs |
1 2 3 | trouble writing output: Too many field references: 131000; max is 65536. You may try using --multi-dex option. | cs |
그럼 이제 다시 본론으로 돌아와 보겠습니다. 앱을 만들던중 다음과 같은 오류가 발생하였습니다.
1 | java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions | cs |
오류의 해결은 다음과 같이 하였습니다. 우선, Application을 상속받는 class를 하나 만들어 줍니다.(이미 있다면 그곳에서 작성하시면됩니다.) 다음은 카카오톡 로그인 기능을 위해 만들어두었던 GlobalApplication.class 입니다.ㅇㅇㅇㅇ
1 2 3 | public class GlobalApplication extends Application{ // 내용은 삭제하였습니다. } | cs |
다음과 같이 Application을 상속받는 class를 만들어주신뒤(이미 있다면 그곳에) 다음과 같이 attachBaseContext 을 override하여줍니다.
1 2 3 4 5 | @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } | cs |
추가를 하였으면 Manifest 파일로 이동하여
1 2 3 4 5 6 7 | <application android:name=".GlobalApplication" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> | cs |
application 부분에서 name 값에 해당 class를 선언하여 줍니다. 다음으로 gradle(Module: app)란으로 이동한 후 다음을 추가시켜줍니다.
1 | compile 'com.android.support:multidex:1.0.1' | cs |
추가 후 위쪽의 defaultConfig 란에서 multiDexEnabled를 추가해줍니다.
1 2 3 | defaultConfig { multiDexEnabled true } | cs |
이제 Sync Now를 눌른뒤 작업이 끝나면 다시 디버깅 또는 빌드를 해보시면 오류없이 정상작동하는것을 보실 수 있습니다.
'안드로이드' 카테고리의 다른 글
[안드로이드] TextView Onclick(클릭 이벤트) (2) | 2017.06.04 |
---|---|
[안드로이드] Okhttp 사용법 (9) | 2017.06.03 |
[안드로이드] app:transformResourcesWithMergeJavaResForDebug' (0) | 2017.05.21 |
[안드로이드] 카카오 SDK 최신 버전 확인 (0) | 2017.05.21 |
[안드로이드] 라이브러리(오픈소스) 모음 (0) | 2017.04.25 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday