LoginSignup
13
7

More than 5 years have passed since last update.

Android Studio 3.0でのGradleプラグインの非互換性

Posted at

まとめ: Gradleプラグイン作者の皆様におかれましては、 Gradle Android Plugin 3.0.0-alpha2 において出力APKファイルに依存するプラグインがだいたい動かなくなりましたので、一度動作を検証されることをお勧めします

高速化のため挙動が変わった部分

Android Plugin からプロジェクトがビルドで出力するAPKファイルを取得したいときは、 variant の outputs から outputFile を参照するってことをやりますが、 3.0.0 から高速化の兼ね合いでこれが参照できなくなりました。

android.applicationVariants.all { variant ->
    variant.outputs.all { output ->
        file = output.outputFile // outputFile が参照できない
    }
}

configuration フェーズだけかと思いきや、ビルドに入っても(実際にそのタスクが走らない限り)参照できないままです。

発生する現象

大体において大変に不幸な感じで、例えば DeployGate の Gradle プラグインだと configuration するだけでも

Error:Could not get unknown property 'variantOutputData' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=prodDebug, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.

なんてエラーで止まって原因の切り分けが困難で(なおこういうときは ./gradlew --stacktrace でスタックトレースが出るので原因を探しやすくなります)、別の例で Fabric Beta にアップロードしようとしてみると、

Error:Execution failed for task ':app:crashlyticsUploadDistributionProdDebug'.
> Not valid.

といった感じで、どちらにしてもとても人間に優しくないエラーメッセージが出ます。

既知の問題で、まだ新APIが実装されてない

ソース: https://developer.android.com/studio/preview/features/new-android-plugin-migration.html#variant_api

API change in variant output

Using the Variant API to manipulate variant outputs is broken with the new plugin.

てなわけで壊れて(broken)ます。壊れてるのは一時的な問題ですが、

As an alternative, we will introduce new APIs to provide similar functionality.

将来的には新しいAPIで対応してねって話になるようなので、更新され次第対応する必要があります。今は大人しく次のバージョンを待つしかない😇

その他参考情報

13
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
7