diff --git a/android/hello_world/.buckconfig b/android/hello_world/.buckconfig new file mode 100644 index 0000000..e0d7b2a --- /dev/null +++ b/android/hello_world/.buckconfig @@ -0,0 +1,11 @@ +[cache] + mode = dir + dir_max_size = 1GB + +[android] + target = android-32 + +[java] + src_roots = /java/ + source_level = 8 + target_level = 8 diff --git a/android/hello_world/.gitignore b/android/hello_world/.gitignore new file mode 100644 index 0000000..df00246 --- /dev/null +++ b/android/hello_world/.gitignore @@ -0,0 +1,35 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/app/build +/captures +.externalNativeBuild +.cxx +local.properties + +app/libs/* + +# Buck +/.buckd +/buck-out +/buck-cache + +# Keystores +# In Buck, all input files must live under the project root. +# Therefore, you need to create the following files in this +# project with your own keystore: +keystore/debug.keystore +# Most likely, you can use the standard debug keystore by running +# the following: +# +# cp ~/.android/debug.keystore keystore/debug.keystore + +third-party \ No newline at end of file diff --git a/android/hello_world/README.md b/android/hello_world/README.md new file mode 100644 index 0000000..0ab1776 --- /dev/null +++ b/android/hello_world/README.md @@ -0,0 +1,55 @@ +This is a sample Android app that can be built with gradle and buck. + +How to build +------------- + +Define ANDROID_SDK environment variable +```shell +export ANDROID_SDK=/home/yourname/Android/Sdk +``` + +Generate a keystore: +```shell +cd keystore +keytool -genkey -keystore debug.keystore -alias my_alias \ +> -keyalg RSA -keysize 2048 -validity 10000 +``` +Update the keystore password in keystore/debug.keystore.properties. + +Create a list of project dependencies +```shell +cd .. +mkdir buck-out +./gradlew -q :app:dependencies --configuration debugCompileClasspath > buck-out/deps.txt +./gradlew -q :app:dependencies --configuration debugRuntimeClasspath >> buck-out/deps.txt +./gradlew -q :app:dependencies --configuration debugAnnotationProcessorClasspath >> buck-out/deps.txt +``` + +Use the import_deps tool to download dependencies and generate BUCK files. +```shell +cd ../import_deps +./importdeps.py --gdeps /Users/mdzyuba/whatsapp/android/tools/buck/hello_world/buck-out/deps.txt --libs third-party +cd ../hello_world +mv ../import_deps/third-party . +``` +Verify the generated third-party BUCK +```shell +buck targets //third-party: +buck build //third-party:core +``` +Start an Android emulator or device. It could be based on SDK Platform v21 - v32. + +To build and install the app, run: +```shell +buck install //app:app +``` +Then run Hello World app on the device. + +Hare is a list of sample buck targets: +```shell +buck build //app:deps +buck build //app:lib +buck build //keystore:debug_keystore +buck build //app:app +``` + diff --git a/android/hello_world/app/BUCK b/android/hello_world/app/BUCK new file mode 100644 index 0000000..abe3f8f --- /dev/null +++ b/android/hello_world/app/BUCK @@ -0,0 +1,51 @@ + +android_library( + name = "deps", + exported_deps = [ + "//third-party/androidx/appcompat:appcompat", + "//third-party/com/google/android/material:material", + "//third-party/androidx/constraintlayout:constraintlayout" + ], + visibility = ["PUBLIC"], +) + +android_build_config( + name = "build_config", + package = "com.example.helloworld", +) + +android_resource( + name = 'res', + res = 'src/main/res', + package = 'com.example.helloworld', + visibility = [ + "PUBLIC", + ], +) + +android_library( + name = 'lib', + srcs = glob(['src/main/java/**/*.java']), + deps = [ + ':res', + ':deps' + ], +) + +android_binary( + name = 'app', + aapt_mode = 'aapt2', + manifest = 'src/main/AndroidManifest.xml', + manifest_entries = { + 'version_code': 1, + 'version_name': '1.0', + 'min_sdk_version': 21, + 'target_sdk_version': 32 + }, + keystore = '//keystore:debug_keystore', + deps = [ + ':lib', + ':res', + ':deps', + ], +) diff --git a/android/hello_world/app/build.gradle b/android/hello_world/app/build.gradle new file mode 100644 index 0000000..3b2d12c --- /dev/null +++ b/android/hello_world/app/build.gradle @@ -0,0 +1,54 @@ +plugins { + id 'com.android.application' +} + +android { + compileSdk 32 + + defaultConfig { + applicationId "com.example.helloworld" + minSdk 21 + targetSdk 32 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation 'androidx.appcompat:appcompat:1.4.1' + implementation 'com.google.android.material:material:1.5.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.3' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' +} + +configurations { + toCopy +} + +dependencies { + toCopy 'androidx.appcompat:appcompat:1.4.1' + toCopy 'com.google.android.material:material:1.5.0' + toCopy 'androidx.constraintlayout:constraintlayout:2.1.3' +} + +task download(type: Copy) { + from configurations.toCopy + into 'libs' +} + + diff --git a/android/hello_world/app/proguard-rules.pro b/android/hello_world/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/android/hello_world/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/android/hello_world/app/src/androidTest/java/com/example/helloworld/ExampleInstrumentedTest.java b/android/hello_world/app/src/androidTest/java/com/example/helloworld/ExampleInstrumentedTest.java new file mode 100644 index 0000000..f8fdd40 --- /dev/null +++ b/android/hello_world/app/src/androidTest/java/com/example/helloworld/ExampleInstrumentedTest.java @@ -0,0 +1,24 @@ +package com.example.helloworld; + +import static org.junit.Assert.*; + +import android.content.Context; +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.example.helloworld", appContext.getPackageName()); + } +} diff --git a/android/hello_world/app/src/main/AndroidManifest.xml b/android/hello_world/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..33f1bc7 --- /dev/null +++ b/android/hello_world/app/src/main/AndroidManifest.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/hello_world/app/src/main/java/com/example/helloworld/MainActivity.java b/android/hello_world/app/src/main/java/com/example/helloworld/MainActivity.java new file mode 100644 index 0000000..95b8780 --- /dev/null +++ b/android/hello_world/app/src/main/java/com/example/helloworld/MainActivity.java @@ -0,0 +1,13 @@ +package com.example.helloworld; + +import android.os.Bundle; +import androidx.appcompat.app.AppCompatActivity; + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + } +} diff --git a/android/hello_world/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/android/hello_world/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/android/hello_world/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/android/hello_world/app/src/main/res/drawable/ic_launcher_background.xml b/android/hello_world/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/android/hello_world/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/hello_world/app/src/main/res/layout/activity_main.xml b/android/hello_world/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..4fc2444 --- /dev/null +++ b/android/hello_world/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/android/hello_world/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/android/hello_world/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/android/hello_world/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/android/hello_world/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/android/hello_world/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/android/hello_world/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/android/hello_world/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/android/hello_world/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 Binary files /dev/null and b/android/hello_world/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/android/hello_world/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/android/hello_world/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d Binary files /dev/null and b/android/hello_world/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/android/hello_world/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/android/hello_world/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 Binary files /dev/null and b/android/hello_world/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/android/hello_world/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/android/hello_world/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d Binary files /dev/null and b/android/hello_world/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/android/hello_world/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/android/hello_world/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 Binary files /dev/null and b/android/hello_world/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/android/hello_world/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/android/hello_world/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 Binary files /dev/null and b/android/hello_world/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/android/hello_world/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/android/hello_world/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 Binary files /dev/null and b/android/hello_world/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/android/hello_world/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/android/hello_world/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 Binary files /dev/null and b/android/hello_world/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/android/hello_world/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/android/hello_world/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 Binary files /dev/null and b/android/hello_world/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/android/hello_world/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/android/hello_world/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 Binary files /dev/null and b/android/hello_world/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/android/hello_world/app/src/main/res/values-night/themes.xml b/android/hello_world/app/src/main/res/values-night/themes.xml new file mode 100644 index 0000000..a956ae7 --- /dev/null +++ b/android/hello_world/app/src/main/res/values-night/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/android/hello_world/app/src/main/res/values/colors.xml b/android/hello_world/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..f8c6127 --- /dev/null +++ b/android/hello_world/app/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/android/hello_world/app/src/main/res/values/strings.xml b/android/hello_world/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..2376a9c --- /dev/null +++ b/android/hello_world/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + HelloWorld + \ No newline at end of file diff --git a/android/hello_world/app/src/main/res/values/themes.xml b/android/hello_world/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..e8e5aa0 --- /dev/null +++ b/android/hello_world/app/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/android/hello_world/app/src/test/java/com/example/helloworld/ExampleUnitTest.java b/android/hello_world/app/src/test/java/com/example/helloworld/ExampleUnitTest.java new file mode 100644 index 0000000..8aaf1ce --- /dev/null +++ b/android/hello_world/app/src/test/java/com/example/helloworld/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package com.example.helloworld; + +import static org.junit.Assert.*; + +import org.junit.Test; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() { + assertEquals(4, 2 + 2); + } +} diff --git a/android/hello_world/build.gradle b/android/hello_world/build.gradle new file mode 100644 index 0000000..2fcc7ef --- /dev/null +++ b/android/hello_world/build.gradle @@ -0,0 +1,9 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +plugins { + id 'com.android.application' version '7.1.2' apply false + id 'com.android.library' version '7.1.2' apply false +} + +task clean(type: Delete) { + delete rootProject.buildDir +} \ No newline at end of file diff --git a/android/hello_world/gradle.properties b/android/hello_world/gradle.properties new file mode 100644 index 0000000..dab7c28 --- /dev/null +++ b/android/hello_world/gradle.properties @@ -0,0 +1,21 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app"s APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Enables namespacing of each library's R class so that its R class includes only the +# resources declared in the library itself and none from the library's dependencies, +# thereby reducing the size of the R class for that library +android.nonTransitiveRClass=true \ No newline at end of file diff --git a/android/hello_world/keystore/BUCK b/android/hello_world/keystore/BUCK new file mode 100644 index 0000000..fc2c8f8 --- /dev/null +++ b/android/hello_world/keystore/BUCK @@ -0,0 +1,6 @@ +keystore( + name = 'debug_keystore', + store = 'debug.keystore', + properties = 'debug.keystore.properties', + visibility = ["PUBLIC"], +) \ No newline at end of file diff --git a/android/hello_world/keystore/debug.keystore.properties b/android/hello_world/keystore/debug.keystore.properties new file mode 100644 index 0000000..60a6691 --- /dev/null +++ b/android/hello_world/keystore/debug.keystore.properties @@ -0,0 +1,3 @@ +key.alias=my_alias +key.store.password=sample +key.alias.password=sample diff --git a/android/hello_world/settings.gradle b/android/hello_world/settings.gradle new file mode 100644 index 0000000..21c5156 --- /dev/null +++ b/android/hello_world/settings.gradle @@ -0,0 +1,16 @@ +pluginManagement { + repositories { + gradlePluginPortal() + google() + mavenCentral() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} +rootProject.name = "HelloWorld" +include ':app'