Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(android,core): allow initializing default Firebase apps via `Fir…
…ebaseOptions.fromResource` on Android (#8566)
- Loading branch information
Showing
12 changed files
with
229 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 26 additions & 32 deletions
58
packages/firebase_core/firebase_core/example/android/app/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,55 @@ | ||
def localProperties = new Properties() | ||
def localPropertiesFile = rootProject.file('local.properties') | ||
if (localPropertiesFile.exists()) { | ||
localPropertiesFile.withReader('UTF-8') { reader -> | ||
localProperties.load(reader) | ||
} | ||
localPropertiesFile.withReader('UTF-8') { reader -> | ||
localProperties.load(reader) | ||
} | ||
} | ||
|
||
def flutterRoot = localProperties.getProperty('flutter.sdk') | ||
if (flutterRoot == null) { | ||
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") | ||
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") | ||
} | ||
|
||
def flutterVersionCode = localProperties.getProperty('flutter.versionCode') | ||
if (flutterVersionCode == null) { | ||
flutterVersionCode = '1' | ||
flutterVersionCode = '1' | ||
} | ||
|
||
def flutterVersionName = localProperties.getProperty('flutter.versionName') | ||
if (flutterVersionName == null) { | ||
flutterVersionName = '1.0' | ||
flutterVersionName = '1.0' | ||
} | ||
|
||
apply plugin: 'com.android.application' | ||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" | ||
|
||
android { | ||
compileSdkVersion 29 | ||
|
||
lintOptions { | ||
disable 'InvalidPackage' | ||
} | ||
|
||
defaultConfig { | ||
applicationId "io.flutter.plugins.firebasecoreexample" | ||
minSdkVersion 21 | ||
targetSdkVersion 28 | ||
versionCode flutterVersionCode.toInteger() | ||
versionName flutterVersionName | ||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
// TODO: Add your own signing config for the release build. | ||
// Signing with the debug keys for now, so `flutter run --release` works. | ||
signingConfig signingConfigs.debug | ||
} | ||
compileSdkVersion flutter.compileSdkVersion | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
|
||
defaultConfig { | ||
applicationId "io.flutter.plugins.firebasecoreexample" | ||
minSdkVersion flutter.minSdkVersion | ||
targetSdkVersion flutter.targetSdkVersion | ||
versionCode flutterVersionCode.toInteger() | ||
versionName flutterVersionName | ||
} | ||
|
||
buildTypes { | ||
release { | ||
signingConfig signingConfigs.debug | ||
} | ||
} | ||
} | ||
|
||
flutter { | ||
source '../..' | ||
source '../..' | ||
} | ||
|
||
dependencies { | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'androidx.test:runner:1.2.0' | ||
androidTestImplementation 'androidx.test:rules:1.2.0' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/firebase_core/firebase_core/example/android/app/src/main/res/values/values.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="default_web_client_id" translatable="false">406099696497-a12gakvts4epfk5pkio7dphc1anjiggc.apps.googleusercontent.com</string> | ||
<string name="firebase_database_url" translatable="false">https://flutterfire-e2e-tests-default-rtdb.europe-west1.firebasedatabase.app</string> | ||
<string name="gcm_defaultSenderId" translatable="false">406099696497</string> | ||
<string name="google_api_key" translatable="false">AIzaSyCdRjCVZlhrq72RuEklEyyxYlBRCYhI2Sw</string> | ||
<string name="google_app_id" translatable="false">1:406099696497:android:0d4ed619c031c0ac3574d0</string> | ||
<string name="google_crash_reporting_api_key" translatable="false">AIzaSyCdRjCVZlhrq72RuEklEyyxYlBRCYhI2Sw</string> | ||
<string name="google_storage_bucket" translatable="false">flutterfire-e2e-tests.appspot.com</string> | ||
<string name="project_id" translatable="false">flutterfire-e2e-tests</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
packages/firebase_core/firebase_core/example/android/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
org.gradle.jvmargs=-Xmx1536M | ||
android.enableR8=true | ||
android.useAndroidX=true | ||
android.enableJetifier=true | ||
org.gradle.daemon=true | ||
org.gradle.caching=true | ||
org.gradle.parallel=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 7 additions & 11 deletions
18
packages/firebase_core/firebase_core/example/android/settings.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
include ':app' | ||
|
||
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() | ||
def localPropertiesFile = new File(rootProject.projectDir, "local.properties") | ||
def properties = new Properties() | ||
|
||
def plugins = new Properties() | ||
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') | ||
if (pluginsFile.exists()) { | ||
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } | ||
} | ||
assert localPropertiesFile.exists() | ||
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } | ||
|
||
plugins.each { name, path -> | ||
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() | ||
include ":$name" | ||
project(":$name").projectDir = pluginDirectory | ||
} | ||
def flutterSdkPath = properties.getProperty("flutter.sdk") | ||
assert flutterSdkPath != null, "flutter.sdk not set in local.properties" | ||
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" |
35 changes: 0 additions & 35 deletions
35
packages/firebase_core/firebase_core/example/lib/firebase_config.dart
This file was deleted.
Oops, something went wrong.
87 changes: 87 additions & 0 deletions
87
packages/firebase_core/firebase_core/example/lib/firebase_options.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// File generated by FlutterFire CLI. | ||
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members | ||
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; | ||
import 'package:flutter/foundation.dart' | ||
show defaultTargetPlatform, kIsWeb, TargetPlatform; | ||
|
||
/// Default [FirebaseOptions] for use with your Firebase apps. | ||
/// | ||
/// Example: | ||
/// ```dart | ||
/// import 'firebase_options.dart'; | ||
/// // ... | ||
/// await Firebase.initializeApp( | ||
/// options: DefaultFirebaseOptions.currentPlatform, | ||
/// ); | ||
/// ``` | ||
class DefaultFirebaseOptions { | ||
static FirebaseOptions get currentPlatform { | ||
if (kIsWeb) { | ||
return web; | ||
} | ||
switch (defaultTargetPlatform) { | ||
case TargetPlatform.android: | ||
return android; | ||
case TargetPlatform.iOS: | ||
return ios; | ||
case TargetPlatform.macOS: | ||
return macos; | ||
default: | ||
throw UnsupportedError( | ||
'DefaultFirebaseOptions are not supported for this platform.', | ||
); | ||
} | ||
} | ||
|
||
static const FirebaseOptions web = FirebaseOptions( | ||
apiKey: 'AIzaSyB7wZb2tO1-Fs6GbDADUSTs2Qs3w08Hovw', | ||
appId: '1:406099696497:web:87e25e51afe982cd3574d0', | ||
messagingSenderId: '406099696497', | ||
projectId: 'flutterfire-e2e-tests', | ||
authDomain: 'flutterfire-e2e-tests.firebaseapp.com', | ||
databaseURL: | ||
'https://flutterfire-e2e-tests-default-rtdb.europe-west1.firebasedatabase.app', | ||
storageBucket: 'flutterfire-e2e-tests.appspot.com', | ||
measurementId: 'G-JN95N1JV2E', | ||
); | ||
|
||
static const FirebaseOptions android = FirebaseOptions( | ||
apiKey: 'AIzaSyCdRjCVZlhrq72RuEklEyyxYlBRCYhI2Sw', | ||
appId: '1:406099696497:android:0d4ed619c031c0ac3574d0', | ||
messagingSenderId: '406099696497', | ||
projectId: 'flutterfire-e2e-tests', | ||
databaseURL: | ||
'https://flutterfire-e2e-tests-default-rtdb.europe-west1.firebasedatabase.app', | ||
storageBucket: 'flutterfire-e2e-tests.appspot.com', | ||
); | ||
|
||
static const FirebaseOptions ios = FirebaseOptions( | ||
apiKey: 'AIzaSyDooSUGSf63Ghq02_iIhtnmwMDs4HlWS6c', | ||
appId: '1:406099696497:ios:acd9c8e17b5e620e3574d0', | ||
messagingSenderId: '406099696497', | ||
projectId: 'flutterfire-e2e-tests', | ||
databaseURL: | ||
'https://flutterfire-e2e-tests-default-rtdb.europe-west1.firebasedatabase.app', | ||
storageBucket: 'flutterfire-e2e-tests.appspot.com', | ||
androidClientId: | ||
'406099696497-tvtvuiqogct1gs1s6lh114jeps7hpjm5.apps.googleusercontent.com', | ||
iosClientId: | ||
'406099696497-taeapvle10rf355ljcvq5dt134mkghmp.apps.googleusercontent.com', | ||
iosBundleId: 'io.flutter.plugins.firebase.tests', | ||
); | ||
|
||
static const FirebaseOptions macos = FirebaseOptions( | ||
apiKey: 'AIzaSyDooSUGSf63Ghq02_iIhtnmwMDs4HlWS6c', | ||
appId: '1:406099696497:ios:acd9c8e17b5e620e3574d0', | ||
messagingSenderId: '406099696497', | ||
projectId: 'flutterfire-e2e-tests', | ||
databaseURL: | ||
'https://flutterfire-e2e-tests-default-rtdb.europe-west1.firebasedatabase.app', | ||
storageBucket: 'flutterfire-e2e-tests.appspot.com', | ||
androidClientId: | ||
'406099696497-tvtvuiqogct1gs1s6lh114jeps7hpjm5.apps.googleusercontent.com', | ||
iosClientId: | ||
'406099696497-taeapvle10rf355ljcvq5dt134mkghmp.apps.googleusercontent.com', | ||
iosBundleId: 'io.flutter.plugins.firebase.tests', | ||
); | ||
} |
Oops, something went wrong.