2016-04-18 11 views
3

私はSQLiteからRealmに切り替えるために働くスタートアップを奨励しようとしています。最大の異論は、それがアプリケーションを作る方法です。コンパイルされたリリースのAPKは、Realm(4MBの違い)後に3.5MBから7.5MBにジャンプします。物理デバイス上のインストール後のサイズは異なるようですが、Nexus 6Pでは19MB(Nexus 5では6MBの差)、Nexus 5では16MBで移動します。サイズを縮小できません。レルムがアプリケーションに追加します

これはRealm docs I期待するべきですが、私はほとんどできないようです。私はhttps://realm.io/docs/java/latest/#how-big-is-the-realm-libraryで説明されているようAPKを分割しようとしたが、私はgradlew installDebugコマンドを実行すると、私はこれらのエラーを取得:

Skipping device 'Nexus 5 - 5.1.1' for 'app:release': Could not find build of variant which supports density 480 and an ABI in armeabi-v7a, armeabi 
Skipping device 'Nexus 6P - 6.0.1' for 'app:release': Could not find build of variant which supports density 560 and an ABI in arm64-v8a, armeabi-v7a, armeabi 

は、与えられたために分割働いて、これだけのネイティブコードAPKを取得する方法はありますデバイスのプロセッサが必要ですか、またはAPKのサイズを下げるために何かできますか?私は、これは巨大な、巨大なサイズの影響ではない限り、物事は行くが、私の上司に懸念し、アプリケーションのサイズに50%を追加することはかなり重要であることを実現します。

Build.gradleファイル、ケースには、それが役立ちます:

// Manifest version information! 
def versionMajor = 1 
def versionMinor = 0 
def versionPatch = 0 
def versionBuild = 0  // bump for dogfood builds, public betas, etc. 

apply plugin: 'com.android.application' 
apply plugin: 'com.neenbedankt.android-apt' 
apply plugin: 'io.fabric' 
apply plugin: 'realm-android' 

android { 
    def globalConfiguration = rootProject.extensions.getByName("ext") 

    compileSdkVersion globalConfiguration.getAt("androidCompileSdkVersion") 
    buildToolsVersion globalConfiguration.getAt("androidBuildToolsVersion") 

    defaultConfig { 
     applicationId "com.gane" 
     minSdkVersion globalConfiguration.getAt("androidMinSdkVersion") 
     targetSdkVersion globalConfiguration.getAt("androidTargetSdkVersion") 
     versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild 
     versionName "${versionMajor}.${versionMinor}.${versionPatch}" 
     vectorDrawables.useSupportLibrary = false 
    } 

    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_7 
     targetCompatibility JavaVersion.VERSION_1_7 
    } 

    packagingOptions { 
     exclude 'LICENSE.txt' 
     exclude 'META-INF/DEPENDENCIES' 
     exclude 'META-INF/ASL2.0' 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/LICENSE' 
    } 

    lintOptions { 
     quiet true 
     abortOnError false 
     ignoreWarnings true 
     disable 'InvalidPackage'   //Some libraries have issues with this. 
     disable 'OldTargetApi' 
     //Lint gives this warning but SDK 20 would be Android L Beta. 
     disable 'IconDensities'    //For testing purpose. This is safe to remove. 
     disable 'IconMissingDensityFolder' //For testing purpose. This is safe to remove. 
    } 

    signingConfigs { 
     debug { 
     } 

     release { 
      storeFile file('matrix') 
      storePassword KEYSTORE_PASSWORD 
      keyAlias 'matrix' 
      keyPassword KEY_PASSWORD 
     } 
    } 

    buildTypes { 
     debug { 
      applicationIdSuffix '.debug' 
      versionNameSuffix '-debug' 

      debuggable true 
      minifyEnabled false 
      shrinkResources false 
      // build.gradle testCoverageEnabled true causes debugger to be unable to view local variables/watches 
      // https://code.google.com/p/android/issues/detail?id=93730 
      // https://code.google.com/p/android/issues/detail?id=123771 
      testCoverageEnabled false 
      ext.enableCrashlytics = false 
     } 

     release { 
      debuggable false 
      minifyEnabled true 
      shrinkResources true 
      testCoverageEnabled false 
      signingConfig signingConfigs.release 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 

     alpha.initWith(buildTypes.release) 
     alpha { 
      minifyEnabled false 
      shrinkResources false 
     } 

     beta.initWith(buildTypes.release) 
     beta { 
      minifyEnabled false 
      shrinkResources false 
     } 
    } 

    splits { 
     abi { 
      enable true 
      reset() 
      include 'arm', 'arm-v7a', 'arm64', 'mips', 'x86', 'x86_64' 
     } 
    } 
} 

dependencies { 
    def appDependencies = rootProject.ext.appDependencies 
    def appTestDependencies = rootProject.ext.appTestDependencies 

    compile appDependencies.supportAppCompact 
    compile appDependencies.supportCardView 
    compile appDependencies.supportDesign 
    compile appDependencies.supportPercent 
    compile appDependencies.supportCustomTabs 

    apt appDependencies.daggerCompiler 
    compile appDependencies.dagger 
    compile appDependencies.butterKnife 
    compile appDependencies.gson 
    compile appDependencies.okHttp 
    compile appDependencies.okHttpUrlConnection 
    compile appDependencies.picasso 
    compile appDependencies.rxJava 
    compile appDependencies.rxAndroid 
    provided appDependencies.javaxAnnotation 

    provided appDependencies.autoValue 
    apt appDependencies.autoValue 

    compile(appDependencies.crashlytics) { 
     transitive = true; 
    } 

    compile(appDependencies.hapiTenantLibrary) { 
     transitive = true 
     exclude module: 'android' 
     exclude module: 'gson' 
     exclude module: 'okhttp' 
     exclude module: 'okhttp-urlconnection' 
     exclude module: 'rxjava' 
    } 

    testCompile appTestDependencies.junit 
    testCompile appTestDependencies.hamcrest 
    // Robolectric to help us test Android based components (Activity, Service, BroadcastReceivers, etc) 
    testCompile(appTestDependencies.robolectric) { 
     exclude group: 'commons-logging', module: 'commons-logging' 
     exclude group: 'org.apache.httpcomponents', module: 'httpclient' 
    } 
    testCompile appTestDependencies.mockito 
    testCompile 'org.apache.maven:maven-ant-tasks:2.1.3' // fixes issue on linux/mac 
} 

android.applicationVariants.all { variant -> 
    def appName 
    //Check if an applicationName property is supplied; if not use the name of the parent project. 
    if (project.hasProperty("applicationName")) { 
     appName = applicationName 
    } else { 
     appName = parent.name 
    } 

    if (variant.buildType.name != "debug" && variant.outputs.zipAlign) { 
     variant.outputs.each { output -> 
      def timestamp = new Date().format("yyyyMMdd-HHmm", TimeZone.getTimeZone("UTC")); 
      def newApkName 
      newApkName = "${appName}-${variant.versionName}-${timestamp}.apk" 
      output.outputFile = new File(output.outputFile.parent, newApkName) 
     } 
    } 
} 
+0

https://github.com/facebook/redex – Abdellah

+0

https://realm.io/docs/java/latest/#how-big-is-the-realm-library – geisshirt

+0

@Abdellah:これも役立つかもしれません私の目標は、Realmのドキュメントができると言ったように、Realmを得ることです。 –

答えて

1

問題が明らかに二重だった:

  1. APK情報を分割するには、ネクサスデバイス用のビルド含まれていませんでした。 Realmがドキュメントを更新したので、それが解決されました。
  2. My GradleファイルにAPKファイルの名前を変更するセクションが追加されました。

APK分割が機能し、APKを管理しやすいサイズにしました。

関連する問題