您的设备与此版本不兼容

时间:2019-08-25 11:56:10

标签: android

我签名的APK大小为61 mb,我知道这就是为什么我尝试从Play商店安装应用时收到此错误的原因,但是我不知道如何减小此APK的大小。我也从代码中删除了不需要的代码,但是仍然可以得到这个大小的APK。

这是清单文件代码:

   <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="8" />

   <uses-feature
           android:name="android.hardware.bluetooth"
           android:required="true" />
   <uses-feature
           android:glEsVersion="0x00020000"
            android:required="true" />

   <uses-feature
            android:name="android.hardware.camera2"
            android:required="true" />

这是我的gradle版本:

         ext {
           minSdkVersion = 17
            targetSdkVersion = 28
            compileSdkVersion = 28
            buildToolsVersion = '28.0.0'

             releaseVersionCode = 1
             releaseVersionName = '1.0.3'
             androidBuildToolsVersion = '28.0.0'
             androidSupportSdkVersion = '28.0.0'

             supportLibraryVersion = '28.0.0'
             gsonVersion = '2.8.0'
             calligraphyVersion = '2.2.0'
             rx2AndroidNetworking = '0.0.1'
             retrofit = '2.1.0'
             picasso = '2.5.2'
             zxing = '3.2.1'
             circularimageview = '3.0.2'
             multidex='1.0.1'
             ormlite='5.0'
             okhttp='2.5.0'
             dagger2Version = '2.8'
             rxjava2Version = '2.0.5'
             rxandroidVersion = '2.0.1'
             butterKnifeVersion = '8.5.1'
             greenDaoVersion = '3.2.0'
             placeholderviewVersion = '0.6.1'
             debugDBVersion = '1.0.0'

             junitVersion = '4.12'
             espressoVersion = '2.2.2'
             mockitoVersion = '2.7.1'
             androidPlugin = 'com.android.tools.build:gradle:3.0.1' }

这是我的gradle库:

       dependencies {
             compile fileTree(include: ['*.jar'], dir: 'libs')
          androidTestCompile('com.android.support.test.espresso:espresso- 
             core:2.2.2', {
           exclude group: 'com.android.support', module: 'support- 
           annotations'
               })
             compile files('libs/ProwessSdkV2.4.6.jar')
             compile "com.android.support:appcompat- 
             v7:$rootProject.supportLibraryVersion"
               compile "com.android.support:recyclerview- 
                  v7:$rootProject.supportLibraryVersion"
               compile "com.android.support:cardview- 
                  v7:$rootProject.supportLibraryVersion"
              compile 
          "com.android.support:design:$rootProject.supportLibraryVersion"
           compile "com.android.support:support-vector- 
         drawable:$rootProject.supportLibraryVersion"
         compile "com.android.support:support- 
           v4:$rootProject.supportLibraryVersion"
            compile 
  "uk.co.chrisjenx:calligraphy:$rootProject.calligraphyVersion"
        compile "com.amitshekhar.android:rx2-android- 
          networking:$rootProject.rx2AndroidNetworking"
        compile "com.google.code.gson:gson:$rootProject.gsonVersion"
         compile "com.google.dagger:dagger:$rootProject.dagger2Version"
           annotationProcessor "com.google.dagger:dagger- 
         compiler:$rootProject.dagger2Version"
          compile 
       "io.reactivex.rxjava2:rxjava:$rootProject.rxjava2Version"
        compile 
          "io.reactivex.rxjava2:rxandroid:$rootProject.rxandroidVersion"

       testCompile 'junit:junit:4.12'
         androidTestCompile('com.android.support.test:runner:0.5') {
           exclude module: 'support-annotations'
                 }
          androidTestCompile('com.android.support.test.espresso:espresso- 
              core:2.2.2') {
                 exclude module: 'support-annotations'
               }
               testCompile "org.mockito:mockito- 
          core:$rootProject.mockitoVersion"
          testAnnotationProcessor "com.google.dagger:dagger- 
                compiler:$rootProject.dagger2Version"
             androidTestCompile 
             "com.android.support.test.espresso:espresso- 
           intents:$rootProject.espressoVersion"
          androidTestCompile "org.mockito:mockito- 
              core:$rootProject.mockitoVersion"
            androidTestAnnotationProcessor "com.google.dagger:dagger- 
        compiler:$rootProject.dagger2Version"
          compile project(':swipereveal')
           compile project(path: ':progressbar')
            compile project(':diagonalprofileview')
             compile project(':flotingspinner')
            compile project(':facerecoglibrary')
          compile project(':facerecognition')
          compile "com.google.code.gson:gson:$rootProject.gsonVersion"
      compile"com.mikhaellopez:circularimageview:
      $rootProject.circularimageview"
           compile "com.squareup.picasso:picasso:$rootProject.picasso"
                 compile "com.google.zxing:core:$rootProject.zxing"
          compile "com.squareup.retrofit2:retrofit:$rootProject.retrofit"
           compile "com.squareup.retrofit2:converter- 
        gson:$rootProject.retrofit"
             compile "com.squareup.retrofit2:converter- 
      jackson:$rootProject.retrofit"
             compile "com.android.support:multidex:$rootProject.multidex"
                compile "com.j256.ormlite:ormlite- 
        android:$rootProject.ormlite"
                   compile 
             "com.squareup.okhttp:okhttp:$rootProject.okhttp"
                   compile project(path: ':floatingbtn')
                  compile project(path: ':navigation')
              compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.+'
             compile 'com.github.pwittchen:reactivenetwork:0.8.0'
          compile 'com.fasterxml.jackson.core:jackson-core:2.8.5'
             compile 'com.fasterxml.jackson.core:jackson- 
          annotations:2.8.5'
          compile 'com.fasterxml.jackson.core:jackson-databind:2.8.5'
            compile 'de.hdodenhof:circleimageview:2.1.0'
             compile 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'
             compile 'javax.inject:javax.inject:1'
             compile 'com.roughike:bottom-bar:2.0.2'
              compile 'com.github.PhilJay:MPAndroidChart:v2.2.4'
           compile 'com.github.gcacace:signature-pad:1.2.1'
          compile 'com.squareup:otto:1.3.8'
          compile 'com.android.support.constraint:constraint- 
          layout:1.0.0-alpha9'
           compile 'com.github.traex.rippleeffect:library:1.3'
              compile 'org.springframework.android:spring-android-rest- 
           template:1.0.1.RELEASE'
                 compile 'com.google.android.gms:play-services- 
           auth:9.8.0'
          compile 'com.google.android.gms:play-services-location:9.8.0'
             androidTestCompile "com.android.support:support- 
               annotations:$rootProject.supportLibraryVersion"
             provided 'javax.annotation:jsr250-api:1.0'
            compile 'com.afollestad.material-dialogs:core:0.9.0.2'
                   compile 'com.github.esafirm.android-image- 
               picker:imagepicker:1.9.0'
}

请让我知道如何处理此源代码,以便减小apk的大小。

1 个答案:

答案 0 :(得分:0)

您可以这样做来减小应用大小(这是一些常见做法):

  • 删除未使用的资源。
  • 最小化库中的资源使用。
  • 仅支持特定密度。
  • 使用可绘制对象。
  • 重复使用资源。
  • 从代码渲染。
  • 压缩PNG文件。
  • 使用tinypng网站压缩要压缩的PNG和JPEG文件 大文件。

除此之外,您还可以尝试

    您添加到代码中的
  • 库可能包含未使用的资源。 Gradle可以代表您自动删除资源 在应用的build.gradle文件中启用shrinkResources

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

我想说的最终最好的方法是Android App Bundle:

Android应用程序捆绑包是一种新的上传格式,其中包含您应用程序的所有已编译代码和资源,但会延迟APK的生成并登录到Google Play。 在开发人员控制台中查看相关内容并进行更改,这肯定会对您有所帮助。