LoginSignup
1
0

More than 1 year has passed since last update.

【Flutter】AndroidのAPKビルドがgradleやAndroid 12のエラーがでて出来ない問題の解決策

Posted at

Android StadioでFlutterのAndroidアプリビルドがうまくいかなかった問題を有志の記事などを参考にしたところ解決することが出来ましたので、やり方を紹介したいと思います。

エラー1

 What went wrong:
Execution failed for task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':flutter_local_notifications:debugUnitTestRuntimeClasspath'.
   > Failed to transform bcprov-jdk15on-1.68.jar (org.bouncycastle:bcprov-jdk15on:1.68) to match attributes {artifactType=processed-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for JetifyTransform: /Users/ryotaro/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bcprov-jdk15on/1.68/46a080368d38b428d237a59458f9bc915222894d/bcprov-jdk15on-1.68.jar.
         > Failed to transform '/Users/ryotaro/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bcprov-jdk15on/1.68/46a080368d38b428d237a59458f9bc915222894d/bcprov-jdk15on-1.68.jar' using Jetifier. Reason: IllegalArgumentException, message: Unsupported class file major version 59. (Run with --stacktrace for more details.)
           Suggestions:
            - Check out existing issues at https://issuetracker.google.com/issues?q=componentid:460323&s=modified_time:desc, it's possible that this issue has already been filed there.
            - If this issue has not been filed, please report it at https://issuetracker.google.com/issues/new?component=460323 (run with --stacktrace and provide a stack trace if possible).a

gradleのバージョンを上げたら解消しました。
gradle-wrapper.propertiesのdistributionUrlを
distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-bin.zip
など、最新のURLに変更して

android/build.gradleのclasspath 'com.android.tools.build:gradle:X.X.X'を

classpath 'com.android.tools.build:gradle:7.1.3'

と変更すると動きました。古いバージョンが指定されていたので、新しいGradleのバージョンとURLをしていしたことによって無事にビルドできるようになったのかと思います。

詳しくは以下の記事を参考にしてみてください
https://www.kentosjpn.com/programming/12/

続いて、

Manifest merger failed : android:exported needs to be explicitly specified 
for element <activity#com.wonder.classtime.wondertime.MainActivity>. 
Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined.
 See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

このようなエラーが出ました。

Android12に対応するには、android:exported="true"をactivityタグに書かないといけないみたいです。

<activity
            android:name=".MainActivity
...

僕の場合は、これでいけましたがうまくいけなかった人は以下の記事に続きが書かれているので参考にしてみてください。
https://crammbon.com/2022/09/05/flutter-android-android-12%E5%AF%BE%E5%BF%9C%E3%81%99%E3%82%8B%E3%81%A8-androidexported-needs-to-be-explicitly-specified-for-element-%E3%81%A8%E6%80%92%E3%82%89%E3%82%8C%E3%81%9F%E6%99%82%E3%81%AE/

1
0
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
1
0