14

cmakeビルドシステムをndk-buildに変更しました。しかし、APKスプリット機能を動作させることはできません。 foo.bar-armeabi-v7a-release-1.5.1.apk - ここABI分割によるexternalNativeBuildの有効化

は私のアプリbuild.gradleファイル

ビルドの結果が一つだけのファイルです。
私は、x86エミュレータ用アプリを構築していた場合、結果はfoo.bar-x86-release-1.5.1.apk

buildscript { 
    repositories { 
     maven { url 'https://maven.fabric.io/public' } 
    } 
    dependencies { 
     classpath 'io.fabric.tools:gradle:1.+' 
    } 
} 
apply plugin: 'com.android.application' 
apply plugin: 'io.fabric' 

repositories { 
    jcenter() 
    maven { url 'https://maven.fabric.io/public' } 
} 

android { 
    compileOptions.encoding = 'ISO-8859-1' 
    compileSdkVersion CompiledSdkVersion 
    buildToolsVersion BuildToolsVersion 

    defaultConfig { 
     applicationId "foo.bar" 
     minSdkVersion MinSdkVersion 
     targetSdkVersion TargetSdkVersion 
     versionCode VersionCode 
     versionName VersionName 
     vectorDrawables.useSupportLibrary = true 

     externalNativeBuild { 
      cmake { 
       cppFlags "-fexceptions", "-std=c++11" 
      } 
     } 

     ndk { 
      abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86", "x86_64" 
     } 
    } 

    signingConfigs { 
     release { 
      storeFile file("..\\release.keystore") 
     } 
    } 

    lintOptions { 
     checkReleaseBuilds false 
     abortOnError false 
    } 

    buildTypes { 
     release { 
      signingConfig signingConfigs.release 
      minifyEnabled true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt' 
     } 
    } 

    splits { 
     abi { 
      enable true 
      reset() 
      include "armeabi", "armeabi-v7a", "arm64-v8a", "mips", "mips64", "x86", "x86_64" 
      universalApk true 
     } 
    } 

    project.ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 5, 'mips64': 6, 'x86': 8, 'x86_64': 9] 
    android.applicationVariants.all { variant -> 
     variant.outputs.each { output -> 
      output.versionCodeOverride = project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.FilterType.ABI), 0) * 1000000 + android.defaultConfig.versionCode 
      output.outputFile = new File(output.outputFile.parent, output.outputFile.name.replace(".apk", "-${variant.versionName}.apk")) 
     } 
    } 

    externalNativeBuild { 
     cmake { 
      path 'src/main/jni/CMakeLists.txt' 
     } 
    } 
} 

crashlytics { 
    enableNdk false // too many reports for third-party modules 
    androidNdkOut '.externalNativeBuild/cmake/release' 
    androidNdkLibsOut 'src/main/libs' 
} 

dependencies { 
    compile project(':common-sources') 
    compile project(':chess-board-library') 
    compile project(':number-picker') 

    compile files('libs/kxml2-2.3.0.jar') 
    compile files('libs/StartADLib-1.0.1.jar') 

    compile Dependencies.appCompat 
    compile Dependencies.cardView 
    compile Dependencies.firebaseAds 
    compile Dependencies.googleAnalytics 
    compile Dependencies.googlePlus 
    compile Dependencies.googleGames 

    compile(Dependencies.crashlytics) { 
     transitive = true 
    } 
    compile(Dependencies.crashlyticsNdk) { 
     transitive = true 
    } 
} 

apply plugin: 'com.google.gms.google-services' 

P.S.ですエラーを再現できるが解決策が見つからない場合は、my issue in Google's bug trackerに投票してください。

答えて

2

これはビルドツールのバグです。 ABI Splitは古いndkビルドでも動作しません。

私は良い回避策を見つけました。コマンドラインからビルド権を開始します。

gradlew assembleDebug 

または

gradlew assembleRelease 

コマンドは、プロジェクトのルートディレクトリから起動する必要があります。されるgetFilterは一つの引数を取りますthis sudden comment :)

1

あなたの問題はあなたのvariants.outputs.eachコードにあるようです。 1つのこととして、getFilterは引数を1つだけ取ります。 (Output classの実装を参照してください。)

com.android.build.OutputFile.ABIを使用しない理由は、this postを参照してください(代わりにOutputFile.FilterType.ABIを使用してください)。この問題により、そのポスターのスプリットAPKの同様の障害が発生しました。

+0

ため

多くのおかげで、それは本当です。コード 'output.getFilter(com.android.build.OutputFile.ABI)'には引数が1つしかありません。私は 'com.android.build.OutputFile.ABI'を' com.android.build.OutputFile.FilterType.ABI'に変更しようとしましたが、これは役に立ちません。 –

+0

申し訳ありませんが、あなたが正しいです、私はコードを誤解しました。違いがあるかどうかを確認するためにコードを単純化しようとするかもしれません。 – Hod

+0

私は実験しようとしましたが、運がありませんでした。このコードはexternalBuildにアップグレードする前に確実に機能していたので、私はそれを信頼します。 –

関連する問題