facebook twitter hatena line email

Unity/バージョンアップメモ/unity2020.1.2f1

提供: 初心者エンジニアの簡易メモ
2021年2月2日 (火) 05:04時点におけるAdmin (トーク | 投稿記録)による版 (android.useAndroidXが設定されてないエラー)

(差分) ←前の版 | 最新版 (差分) | 次の版→ (差分)
移動: 案内検索

unity2020.1.2f1へ

unity2019.2.12f1からunity2020.1.2f1へ

Component GUI Layerエラーが出るとき

Component GUI Layer in Main Camera for Scene unity is no longer available.
It will be removed after you edit this GameObject and save the Scene.

MainCameraのFlareLayerをremoveするとよい。

参考:https://baba-s.hatenablog.com/entry/2020/05/07/070100

Deterministic compilation failed. You can disable Deterministic builds in Player Settingsエラーが出るとき

Edit/"Project Settings"/"Other Setting"/"Use deterministic compilation"のチェックボックスのチェックをはすず

参考:https://mukolog.com/20200814-unity-error/

androidのとき

android.useAndroidXが設定されてないエラー

以下のようなメッセージが出た場合

* What went wrong:
Could not determine the dependencies of task ':launcher:lintVitalRelease'.
> This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.
The following AndroidX dependencies are detected: androidx.versionedparcelable:versionedparcelable:1.0.0, androidx.fragment:fragment:1.0.0, androidx.slidingpanelayout:slidingpanelayout:1.0.0, androidx.core:core:1.0.0, androidx.customview:customview:1.0.0, androidx.swiperefreshlayout:swiperefreshlayout:1.0.0, androidx.interpolator:interpolator:1.0.0, androidx.loader:loader:1.0.0, androidx.drawerlayout:drawerlayout:1.0.0, androidx.viewpager:viewpager:1.0.0, androidx.collection:collection:1.0.0, androidx.localbroadcastmanager:localbroadcastmanager:1.0.0, androidx.lifecycle:lifecycle-common:2.0.0, androidx.arch.core:core-common:2.0.0, androidx.annotation:annotation:1.1.0, androidx.legacy:legacy-support-core-ui:1.0.0, androidx.lifecycle:lifecycle-livedata:2.0.0, androidx.lifecycle:lifecycle-viewmodel:2.0.0, androidx.lifecycle:lifecycle-livedata-core:2.0.0, androidx.browser:browser:1.0.0, androidx.arch.core:core-runtime:2.0.0, androidx.legacy:legacy-support-core-utils:1.0.0, androidx.documentfile:documentfile:1.0.0, androidx.cursoradapter:cursoradapter:1.0.0, androidx.lifecycle:lifecycle-runtime:2.0.0, androidx.coordinatorlayout:coordinatorlayout:1.0.0, androidx.asynclayoutinflater:asynclayoutinflater:1.0.0, androidx.print:print:1.0.0

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

AndroidのPublisingSettingのCustomGradlePropertiesTemplateにチェックを付け、生成されたgradleTemplate.propertiesに以下を追加

Assets/Plugins/Android/gradleTemplate.properties

android.enableJetifier=true
android.useAndroidX=true
androidx対応して、R8系のエラーが出たとき

以下メッセージが出たとき

It will be removed in a future version of the Android Gradle plugin, and will no longer allow you to disable R8.

以下を追加すれば解決した。

Assets/Plugins/Android/mainTemplate.gradle

([rootProject] + (rootProject.subprojects as List)).each {
    ext {
        it.setProperty("android.useAndroidX", true)
        it.setProperty("android.enableJetifier", true)
    }
}

firebase-xxxx-unity.jarがない

以下のようなエラーが出るとき

> Could not find firebase-analytics-unity.jar (com.google.firebase:firebase-analytics-unity:6.10.0).
> Could not find firebase-app-unity.jar (com.google.firebase:firebase-app-unity:6.10.0).
> Could not find firebase-auth-unity.jar (com.google.firebase:firebase-auth-unity:6.10.0).
> Could not find firebase-config-unity.jar (com.google.firebase:firebase-config-unity:6.10.0).
> Could not find firebase-crashlytics-unity.jar (com.google.firebase:firebase-crashlytics-unity:6.10.0).
> Could not find firebase-functions-unity.jar (com.google.firebase:firebase-functions-unity:6.10.0).

firebaseを再度downloadして(firebase_unity_sdk_6.15.2.zip)各種unitypackageをインストールする。

GoogleMobileAds周りのエラーのとき

Assets/GoogleMobileAdsを最新のGoogleMobileAds5.3.0 (https://github.com/googleads/googleads-mobile-unity/releases/tag/v5.3.0) をインポート

java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException:

Assets/Plugin/Android/GoogleMobileAdsPluginを削除して、最新のGoogleMobileAds5.3.0 をimport

AndroidManifest.xml is missing

以下エラーが発生した場合

BuildMethodException: [GoogleMobileAds] AndroidManifest.xml is missing. Try re-importing the plugin.
ManifestProcessor.StopBuildWithMessage (System.String message) (at 

Assets/Plugins/Android/GoogleMobileAdsPluginを一度消して、もう一度importする(Assets/Plugins/Android/GoogleMobileAdsPlugin.androidlib)が入るはず。

参考:https://github.com/googleads/googleads-mobile-unity/issues/1296

multidexのエラーが出るとき

以下エラーが出るとき

com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 

以下ファイルにmultiDexEnabledを追加する

Assets/Plugins/Android/mainTemplate.gradle

android {
    defaultConfig {
        multiDexEnabled true
    }
}
dependencies {
    implementation 'androidx.multidex:multidex:2.0.1'
}

androidxでなくandroid.supportを使ってる場合はこちら、

implementation 'com.android.support:multidex:1.0.3'

AndroidManifext.xml

<application
    android:name="android.support.multidex.MultiDexApplication" >
    <!-- If you are using androidx use android:name="androidx.multidex.MultiDexApplication" -->

参考:Unity/GoogleMobileSDK/ライブラリ自動読み込み [ショートカット]

参考:https://developer.android.com/studio/build/multidex?hl=ja#java

複数のBuildConfigが登録されてるエラーが出るとき

以下のようなエラーが出るとき

com.android.build.gradle.internal.tasks.Workers$ActionFacade
Type com.google.unity.BuildConfig is defined multiple times: 
/Users/mac1/.gradle/caches/transforms-2/files-2.1/c9cf383e15a96332348d065caa0c331b/jetified-googlemobileads-unity-runtime/classes.dex, 
Temp/gradleOut/launcher/build/intermediates/external_file_lib_dex_archives/release/out/0_jetified-unity-plugin-library.jar:classes.dex
  • バージョンアップでcom.google.unity.BuildConfigの競合が起こってるので、アプリ下のTempを一旦削除すれば良い。
  • Assets/Plugins/x86_64/Firebaseもfirebase-6.15.2では不要っぽいので削除。

compileSdkVersionがないとき

以下メッセージが出るとき、compileSdkVersionがAssets/Plugins/Android/mainTemplate.gradleに含まれてないので確認する。

A problem occurred configuring project ':unityLibrary'.
> compileSdkVersion is not specified. Please add it to build.gradle

bundle()メソッドが見つからないと出るとき

以下メッセージが出るとき

A problem occurred evaluating project ':unityLibrary'.
> Could not find method bundle() for arguments

Assets/Plugins/Android/mainTemplate.gradleに以下のようにbundleがある場合は、コメントアウトしておく。

/*
bundle {
        language {
            enableSplit = false
        }
        density {
            enableSplit = false
        }
        abi {
            enableSplit = true
        }
    }
*/

参考:https://stackoverflow.com/questions/54234394/how-to-resolve-could-not-find-method-bundle-for-arguments-build-6plat21h

ライブラリプロジェクトはapplicationIdを設定できませんと出るとき

以下メッセージが出るとき

 Library projects cannot set applicationId. applicationId is set to  in default config.

Assets/Plugins/Android/mainTemplate.gradleにapplicationIdが含まれてるときは、削除する

google-services.json がないと出るとき

以下メッセージが出るとき

Failed to read Firebase options from the app's resources. Either make sure google-services.json is included in your build or specify options explicitly.

Assets/Plugins/Android/mainTemplate.gradle に以下sourceSetsを追加

android {
    sourceSets {
        main {
            res.srcDirs += '/d/www/unity/project1/Assets/Plugins/Android/Firebase/res/values/google-services.xml'
        }
    }
}

/d/www/unity/project1/の部分は適宜修正ください。

Crashlytics build IDがミスしてると出るとき

E FirebaseCrashlytics: The Crashlytics build ID is missing. This occurs when Crashlytics tooling is absent from your app's build configuration. Please review Crashlytics onboarding instructions and ensure you have a valid Crashlytics account.

Packages/manifest.jsonから一旦crashlyticsを消す。

Failed to update Android SDK package list. See the Console for details.エラーが出るとき

Unity/開発環境/Android [ショートカット]] sdkmanagerから対象APIのsdkをインストール

com.unity.purchasing.googleplay.GooglePlayPurchasingが見つからず課金処理が停止する

Unity/課金/インストール [ショートカット] こちらを確認

iosのとき

using manual reference counting エラー1

以下エラーが出るとき(UnityEarlyTransactionObserver.mmで起こった)

Cannot synthesize weak property in file using manual reference counting

BuildSettingからWeak References in Manual Retain ReleaseをNoからYesへ

using manual reference countingエラー2

以下エラーが出るとき(Libraries/Plugins/iOS/GADUNativeCustomTemplateAd.mm で起こった)

Cannot create __weak reference in file using manual reference counting

BuildSettingからWeak References in Manual Retain ReleaseをNoからYesへ(Levelsを選択してすべてをYesへ)