2016-03-28 3 views
1

У меня есть андроид приложение, которое используется kinvey, и он работал хорошо со мной вдруг я получилAndroid Kinvey java.lang.NoClassDefFoundError

java.lang.OutOfMemoryError: GC overhead limit exceeded

так я поставил

dexOptions { 
    incremental true 
    javaMaxHeapSize "4g" 
}   

в моем Gradle файле, но затем я получил java.lang.NoClassDefFoundError в строке, когда я создаю новый клиент

mKinveyClient = new Client.Builder(AP_ID,App_Secret, this).build(); 

я пытался очистить проект, чистый град le file, обновил мой kinvey sdk с 1,5 до 1,6 Любые предложения?

вот мой build.gradle файл

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.2" 
    dexOptions { //for the error java.lang.OutOfMemoryError: GC overhead limit exceeded 
     incremental true 
     javaMaxHeapSize "4g" 
    }  

    defaultConfig { 
     applicationId "com.example.dell.augmentedreality" 
     minSdkVersion 14 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
     multiDexEnabled = true 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

repositories { 
    jcenter() 

    flatDir { 
     dirs 'libs' 
    } 

    mavenCentral() 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile 'com.android.support:appcompat-v7:23.1.1' 
    compile files('src/main/java/Vuforia.jar') 
    compile(name:'kinvey-android-2.10.6', ext:'aar') {changing= true} 
    compile 'com.android.support:multidex:1.0.0' 
    compile 'com.gordonwong:material-sheet-fab:1.2.1' 
    compile 'com.android.support:design:23.1.1' 
    compile 'com.android.support:recyclerview-v7:23.0.1' 
    ///////////////////////////for animating the text 
    /////////////////////// 
    compile 'com.nineoldandroids:library:2.4.0' 
    compile 'com.daimajia.easing:library:[email protected]' 
    compile 'com.daimajia.androidanimations:library:[email protected]' 
    ///////////////google cloud messaging 
    compile 'com.google.android.gms:play-services:8.4.0' 
} 

Edit: в изображении ниже моих банок файлы

enter image description here

+0

Предполагая, что вы используете Android Studio, вы видите библиотеки Kinvey при расширении «Внешних библиотек» в панели проекта? – Bajal

+0

файл jars на изображении есть ли что-то не так с ним? –

+0

Можете ли вы показать полную 'build.gradle', пожалуйста? –

ответ

1

Я думаю, что проблема в том, что вы скопировали файл JAR Kinvey и файл AAR в папку libs/. Вам нужен только AAR.

Класс, который утверждал, что отсутствует, com.google.api.client.json.JsonObjectParser, содержатся в google-http-client-1.19-0.jar, так добавив, что файл JAR для правильного libs/ каталога в модуле и в том числе этих строк в вас build.gradle должны правильно найти этот класс без ошибок.

repositories { 
    flatDir { 
     dirs 'libs' 
    } 
} 

dependencies {  
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile(name:'kinvey-android-*', ext:'aar') 

    // other stuff 
} 

касаемо OutOfMemory ошибки, вы, скорее всего, превысил Android Dex method limit из-за того, сколько зависимостей вы включили. В частности, последняя строка вашего файла gradle для зависимости play-services. Если вы читаете that documentation, вы увидите примечание, которое говорит

Note: If the number of method references in your app exceeds the 65K limit, your app may fail to compile. You may be able to mitigate this problem when compiling your app by specifying only the specific Google Play services APIs your app uses, instead of all of them.

Поскольку вы, кажется, хотят только облако сообщений, вы можете просто включить, что один, поэтому заменить эту строку.

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

С этим одним

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

И любой other Play Services вы хотите включить.

+1

, когда я сменил строку сервиса Google Play, он сработал вам большое спасибо –

0

i got java.lang.NoClassDefFoundError

Вы включили неправильно Dependent баночку. Добавьте подходящую зависимую версию jar, используя maven или gradle.

+0

Это, очевидно, проблема ... Если вы включили какую-нибудь флягу, тогда этот ответ был бы полезен. –

+1

Я следил за этой ссылкой http://devcenter.kinvey.com/android/guides/getting-started Я не знаю, какие файлы jar ошибаются, можете ли вы мне рассказать? –

Смежные вопросы