diff --git a/.editorconfig b/.editorconfig index d2ff04496..093f3a5ed 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,2 +1,3 @@ [*.{java,kt}] max_line_length = 120 +indent_size = 2 diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 000000000..f53ebbb97 --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,24 @@ +name: Android CI + +on: + - pull_request + - push + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Check Snippets + run: python scripts/checksnippets.py + - name: set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: temurin + - name: Build with Gradle (Pull Request) + run: ./build_pull_request.sh + if: github.event_name == 'pull_request' + - name: Build with Gradle (Push) + run: ./gradlew clean ktlint build + if: github.event_name != 'pull_request' diff --git a/.gitignore b/.gitignore index 0b2687911..4593b25c3 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ build/ *.aar *.zip .vscode +.project +.settings +.classpath diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b1da73049..000000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -language: android -jdk: oraclejdk8 -sudo: required -before_cache: - - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ -cache: - directories: - - $HOME/.gradle/caches/ - - $HOME/.gradle/wrapper/ - - $HOME/.android/build-cache -before_install: - - yes | sdkmanager "platforms;android-28" - - yes | sdkmanager "platforms;android-29" - - mkdir "$ANDROID_HOME/licenses" || true - - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55\nd56f5187479451eabf01fb78af6dfcb131a6481e" > "$ANDROID_HOME/licenses/android-sdk-license" - - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd\n504667f4c0de7af1a06de9f4b1727b84351f2910" > "$ANDROID_HOME/licenses/android-sdk-preview-license" -android: - components: - - tools - - build-tools-28.0.3 - - build-tools-29.0.0 - - tools - licenses: - - android-sdk-preview-license-.+ - - android-sdk-license-.+ - - google-gdk-license-.+ -script: - - python scripts/checksnippets.py - - ./gradlew clean ktlint build diff --git a/README.md b/README.md index 1e2ebad3b..a3b9312d0 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,7 @@ on [firebase.google.com](https://firebase.google.com/docs/). We love contributions! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines. -[![Build Status](https://travis-ci.org/firebase/snippets-android.svg?branch=master)](https://travis-ci.org/firebase/snippets-android) +[![Actions Status][gh-actions-badge]][gh-actions] + +[gh-actions]: https://github.com/firebase/snippets-android/actions +[gh-actions-badge]: https://github.com/firebase/snippets-android/workflows/Android%20CI/badge.svg \ No newline at end of file diff --git a/admob/app/build.gradle b/admob/app/build.gradle deleted file mode 100644 index 3ec3ac299..000000000 --- a/admob/app/build.gradle +++ /dev/null @@ -1,32 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' - -android { - compileSdkVersion 29 - - defaultConfig { - applicationId "com.google.firebase.example.admob" - minSdkVersion 16 - targetSdkVersion 29 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'androidx.browser:browser:1.0.0' - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation "com.google.firebase:firebase-ads:18.3.0" - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61" -} - -apply plugin: 'com.google.gms.google-services' diff --git a/admob/app/build.gradle.kts b/admob/app/build.gradle.kts new file mode 100644 index 000000000..927ef663c --- /dev/null +++ b/admob/app/build.gradle.kts @@ -0,0 +1,53 @@ +plugins { + id("com.android.application") + id("kotlin-android") + id("com.google.gms.google-services") +} + +android { + namespace = "com.google.firebase.example.admob" + compileSdk = 36 + + defaultConfig { + applicationId = "com.google.firebase.example.admob" + minSdk = 23 + targetSdk = 36 + versionCode = 1 + versionName = "1.0" + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + multiDexEnabled = true + } + buildTypes { + getByName("release") { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = "17" + } +} + +dependencies { + implementation("androidx.legacy:legacy-support-v4:1.0.0") + implementation("androidx.browser:browser:1.5.0") + implementation("androidx.appcompat:appcompat:1.7.1") + implementation("com.google.firebase:firebase-ads:23.6.0") + implementation("androidx.constraintlayout:constraintlayout:2.2.1") + implementation("androidx.multidex:multidex:2.0.1") + + // [START gradle_play_config] + implementation("com.google.android.gms:play-services-ads:24.7.0") + // [END gradle_play_config] + + // Import the Firebase BoM (see: https://firebase.google.com/docs/android/learn-more#bom) + implementation(platform("com.google.firebase:firebase-bom:34.5.0")) + + // For an optimal experience using AdMob, add the Firebase SDK + // for Google Analytics. This is recommended, but not required. + implementation("com.google.firebase:firebase-analytics") +} diff --git a/admob/app/proguard-rules.pro b/admob/app/proguard-rules.pro index af6097fd5..4f3270429 100644 --- a/admob/app/proguard-rules.pro +++ b/admob/app/proguard-rules.pro @@ -2,7 +2,7 @@ # By default, the flags in this file are appended to flags specified # in /Users/ianbarber/Library/Android/sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. +# directive in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/admob/app/src/main/AndroidManifest.xml b/admob/app/src/main/AndroidManifest.xml index 9a8cb74a6..eea1a17de 100644 --- a/admob/app/src/main/AndroidManifest.xml +++ b/admob/app/src/main/AndroidManifest.xml @@ -1,6 +1,6 @@ + xmlns:tools="http://schemas.android.com/tools"> - + + diff --git a/admob/app/src/main/java/com/google/firebase/example/admob/MainActivity.java b/admob/app/src/main/java/com/google/firebase/example/admob/MainActivity.java index d8c706f93..c35e46b7d 100644 --- a/admob/app/src/main/java/com/google/firebase/example/admob/MainActivity.java +++ b/admob/app/src/main/java/com/google/firebase/example/admob/MainActivity.java @@ -1,6 +1,7 @@ package com.google.firebase.example.admob; import android.os.Bundle; + import androidx.appcompat.app.AppCompatActivity; import com.google.android.gms.ads.MobileAds; @@ -12,8 +13,7 @@ public class MainActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ... - // Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 - MobileAds.initialize(this, "YOUR_ADMOB_APP_ID"); + MobileAds.initialize(this); } // [END ads_on_create] diff --git a/admob/app/src/main/java/com/google/firebase/example/admob/kotlin/MainActivity.kt b/admob/app/src/main/java/com/google/firebase/example/admob/kotlin/MainActivity.kt index c058a8a60..62f780441 100644 --- a/admob/app/src/main/java/com/google/firebase/example/admob/kotlin/MainActivity.kt +++ b/admob/app/src/main/java/com/google/firebase/example/admob/kotlin/MainActivity.kt @@ -10,8 +10,7 @@ class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // ... - // Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 - MobileAds.initialize(this, "YOUR_ADMOB_APP_ID") + MobileAds.initialize(this) } // [END ads_on_create] } diff --git a/admob/app/src/main/res/layout/activity_main.xml b/admob/app/src/main/res/layout/activity_main.xml index 3e3fc69be..c5540456d 100644 --- a/admob/app/src/main/res/layout/activity_main.xml +++ b/admob/app/src/main/res/layout/activity_main.xml @@ -1,18 +1,49 @@ - + + + + + +