2017-09-16 3 views
0

나는이 질문이 백만 번 요구되었지만 아직 구체적인 상황에 대한 답을 찾을 수 없다는 것을 알고 있습니다. 나는 모든 코드와 라이브러리를 가져 오는 몇 가지 다른 모듈을 가진 라이브러리를 가지고있다.java.lang.RuntimeException : 응용 프로그램을 인스턴스화 할 수 없습니다. ClassNotFoundException : 클래스를 찾지 못했습니다

두 매니페스트는 이와 같은 기본 앱을 사용합니다.

<application 
    android:name="co.android.mylibrary.BaseApp" 
    android:allowBackup="false" 
    android:fullBackupContent="false" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:largeHeap="true" 
    android:theme="@style/AppTheme" 
    tools:replace="android:icon,android:theme, android:allowBackup"> 

그리고 빌드 의존성는 다음과 같다 :

dependencies { 
    releaseCompile project(path: ':mylibrary', configuration: 'release') 
    debugCompile project(path: ':mylibrary', configuration: 'debug') 
} 

내 기본 응용 프로그램의 방법은 초기화 multidex :

protected void attachBaseContext(Context base) { 
    super.attachBaseContext(base); 
    try { 
     MultiDex.install(this); 
    }catch (RuntimeException e){} 
} 

나는 모두에 추가 한 나의 난독 화 규칙의 일부, 위치 (라이브러리 및 응용 프로그램). 여기에는 타사 라이브러리 및 일부 클래스에 대한 일부 규칙이 포함되지 않습니다.

-keep public class * extends android.app.Activity 
-keep public class * extends android.app.Application 
-keep public class * extends android.app.Service 
-keep public class * extends android.content.BroadcastReceiver 
-keep public class * extends android.content.ContentProvider 
-keep public class * extends android.view.View 
-keep public class co.android.mylibrary.data.greendao.**{ *; } 

그래서 응용 프로그램 내 S8에 잘 실행되지만 Proguard와는 릴리스 빌드에 대한처럼, 그 축소 자원을 활성화되면 모토 G. 같은 일부 휴대 전화에 그들은 또한 잘 실행 할 수 없습니다. 내가 알아챈 또 다른 이상한 동작은 코드의 일부분에 브레이크 포인트를 설정하고 릴리스 빌드를 실행하면 (디버그 가능이 true로 설정된 경우) s8에서 중단되지만 모토에서는 중단되지 않는다는 것입니다.

왜 이상한 행동입니까? 다른 비슷한 질문은 unable to instantiate application - ClassNotFoundException입니다. 그러나 여전히 해결책은 없습니다.

이것은 오류의 전체 로그입니다. 패키지 이름을 무시하십시오. Exception log

@Mostafa Anter에서 suggestiongs에 따라 내 응용 프로그램에 라이브러리를 컴파일하는 방식을 변경 한 후 편집

: 그것은 나에게 오류를주고 시작

compile project(path: ':mylibrary', configuration: 'debug') 

. 나는 즉시 뛰게했다.

Class not found exception on Firebase.initProvider

+0

ClassNotFoundException의 logcat 세부 정보를 표시 할 수 있습니까? – JRG

답변

0

메이크업베이스 클래스 Application 다음에서 onCreate 메소드 호출이 회선 MultiDex.install(this);

, multidex을 활성화 종속성으로 multidex 라이브러리를 추가 모듈 수준 build.gradle 파일을 수정 내부에 도시 된 바와 같이 확장 여기 :

android { 
defaultConfig { 
    ... 
    minSdkVersion 15 
    targetSdkVersion 26 
    multiDexEnabled true 
} 
... 
} 

dependencies { 
    compile 'com.android.support:multidex:1.0.1' 
} 
+0

그 일을 이미하고 있습니다. – user2130331

+0

당신은 프로 가드를 사용하고 있습니까? 그렇다면 우리에게 규칙을 제공하십시오 –

+0

이 줄을 progaurd -keep public class your_missing_class_full_name –

0

당신이 JavaVersion.VERSION_1_8를 사용하는 경우는 모든 모듈

에서 사용 있는지 확인하십시오
android { 
    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_8 
     targetCompatibility JavaVersion.VERSION_1_8 
    } 
}