以下の説明の通りに設定したのですがエラーが発生しました。どのように解決したらよいのでしょうか。
https://blog.codecamp.jp/programming-first-android-app-development
apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' android { compileSdkVersion 28 defaultConfig { multiDexEnabled true applicationId "com.example.XXX" minSdkVersion 16 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } dependencies { implementation 'com.google.firebase:firebase-messaging:20.0.0' implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.multidex:multidex:2.0.1' implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.google.firebase:firebase-core:17.2.0' implementation 'com.google.firebase:firebase-firestore:21.0.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' }
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.example.XXX"> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <application tools:replace="android:appComponentFactory" android:appComponentFactory="whateverString" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <service android:name=".MyFirebaseMessagingService" android:exported="false"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service> </application> </manifest>
URLは https://teratail.com/help/question-tips#questionTips3-7 の [リンク] に修正してください。
「以下の説明の通り」と記されていますが、説明通りになっていないように思えます。"apply plugin: 'com.google.gms.google-services'"はbuild.gradleの末尾に置くように記述されています。また、Firebaseのライブラリーを最新版とするならば、AndroidXを用いる必要があるでしょう。ご提示のコードは従来のSupport Libraryのままになっているので、その部分でエラーになっているのかもしれません。
ありがとうございます。AndroidXを使用しない方法で行いたいのですが、その場合バージョンはどのようにすれば良いのでしょうか。
https://firebase.google.com/support/release-notes/android
このページにFirebaseのリリースノートがあります。"Update - June 17, 2019"の更新によってAndroidXに移行しているので、その下の方を辿って移行前のバージョンを探すことになるんじゃないでしょうか。
解決しました。ありがとうございました。
解決されたのであれば、そこに至った内容を自己回答して、それをベストアンサーとしてください。ただ、AndroidXを用いないということは、今後のGoogle APIやFirebaseの更新を一切利用できないことを意味します。今は参考にしたページと異なる要因を増やしたくないなどの理由があるのかもしれませんが、いずれAndroidXは避けて通れないものと考えておくべきだと思います。
あなたの回答
tips
プレビュー