Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions templates/Native-Logging-Demos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# The bundle and its provenance record are generated by the publish workflow.
# Neither is ever committed — see templates/README.md, "Build provenance".
*.cgt
cgt-build.properties
83 changes: 83 additions & 0 deletions templates/Native-Logging-Demos/NativeLogDemoC/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Built application files
*.apk
*.aar
*.ap_
*.aab

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
/bin/
/gen/
/out/
# Uncomment the following line in case you need and you don't have the release build type files in your app
# Gradle files
.gradle/
/build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml

# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
.cxx/

# Google Services (e.g. APIs or Firebase)
# google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md

# Version control
vcs.xml

# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
165 changes: 165 additions & 0 deletions templates/Native-Logging-Demos/NativeLogDemoC/app/build.gradle.kts.peb
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@

import java.util.Properties
import java.io.FileInputStream

plugins {
alias(libs.plugins.android.application)
}

val keystorePropsFile = rootProject.file("release.properties")
val keystoreProps = Properties()

if (keystorePropsFile.exists()) {
keystoreProps.load(FileInputStream(keystorePropsFile))
}

val hasValidSigningProps = keystorePropsFile.exists().also { exists ->
if (exists) {
FileInputStream(keystorePropsFile).use { keystoreProps.load(it) }
}
}.let {
listOf("storeFile", "storePassword",
"keyAlias", "keyPassword").all { key ->
keystoreProps[key] != null
}
}


android {
namespace = "${{PACKAGE_NAME}}"
compileSdk = ${{COMPILE_SDK}}

// disable linter
lint {
checkReleaseBuilds = false
}

signingConfigs {
if (hasValidSigningProps) {
create("release") {
storeFile = rootProject.file(keystoreProps["storeFile"] as String)
storePassword = keystoreProps["storePassword"] as String
keyAlias = keystoreProps["keyAlias"] as String
keyPassword = keystoreProps["keyPassword"] as String
}
}
}

defaultConfig {
applicationId = "${{PACKAGE_NAME}}"
minSdk = ${{MIN_SDK}}
targetSdk = ${{TARGET_SDK}}
versionCode = 1
versionName = "1.0"

vectorDrawables {
useSupportLibrary = true
}

// The NDK installed by the NDK-Installer plugin targets 64-bit ARM.
ndk {
abiFilters += "arm64-v8a"
}
}

// Must match the NDK the NDK-Installer plugin unpacks into the SDK.
ndkVersion = "29.0.14206865"

externalNativeBuild {
cmake {
path = file("src/main/cpp/CMakeLists.txt")
}
}

compileOptions {
sourceCompatibility = ${{JAVA_SOURCE_COMPAT}}
targetCompatibility = ${{JAVA_TARGET_COMPAT}}
}

buildTypes {
release {
if (hasValidSigningProps) {
signingConfig = signingConfigs.getByName("release")
}
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}

buildFeatures {
viewBinding = true

}
packaging {
resources {
resources.excludes.add("/META-INF/{AL2.0,LGPL2.1}")
resources.excludes.add("META-INF/kotlinx_coroutines_core.version")

// The part below is only needed for compose builds.
// This packaging block is required to solve interdependency conflicts.
// They arise only when using local maven repo, so I suppose online repos have some way of solving such issues.

// Caused by: com.android.builder.merge.DuplicateRelativeFileException: 4 files found with path 'commonMain/default/linkdata/module' from inputs:
// - AndroidIDE\libs_source\gradle\localMvnRepository\androidx\collection\collection\1.4.2\collection-1.4.2.jar
// - AndroidIDE\libs_source\gradle\localMvnRepository\androidx\lifecycle\lifecycle-common\2.8.7\lifecycle-common-2.8.7.jar
// - AndroidIDE\libs_source\gradle\localMvnRepository\androidx\annotation\annotation\1.8.1\annotation-1.8.1.jar
// - AndroidIDE\libs_source\gradle\localMvnRepository\org\jetbrains\kotlinx\kotlinx-coroutines-core\1.7.3\kotlinx-coroutines-core-1.7.3.jar
// And some others.
resources.pickFirsts.add("nonJvmMain/default/linkdata/package_androidx/0_androidx.knm")
resources.pickFirsts.add("nonJvmMain/default/linkdata/root_package/0_.knm")
resources.pickFirsts.add("nonJvmMain/default/linkdata/module")

resources.pickFirsts.add("nativeMain/default/linkdata/root_package/0_.knm")
resources.pickFirsts.add("nativeMain/default/linkdata/module")

resources.pickFirsts.add("commonMain/default/linkdata/root_package/0_.knm")
resources.pickFirsts.add("commonMain/default/linkdata/module")
resources.pickFirsts.add("commonMain/default/linkdata/package_androidx/0_androidx.knm")

resources.pickFirsts.add("META-INF/kotlin-project-structure-metadata.json")

resources.merges.add("commonMain/default/manifest")
resources.merges.add("nonJvmMain/default/manifest")
resources.merges.add("nativeMain/default/manifest")
}
}

configurations.all {
resolutionStrategy {
// Force the use of Kotlin stdlib 1.9.22 for all modules
force("org.jetbrains.kotlin:kotlin-stdlib:${{KOTLIN_VERSION}}")
force("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${{KOTLIN_VERSION}}")
force("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${{KOTLIN_VERSION}}")

// Force specific AndroidX versions to avoid conflicts
force("androidx.collection:collection:1.4.2")
force("androidx.annotation:annotation:1.8.1")
force("androidx.core:core-ktx:1.8.0")
force("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1")
force("androidx.collection:collection-ktx:1.4.2")
}
}
}

tasks.withType<JavaCompile> {
options.compilerArgs.add("-Xlint:deprecation")
}

${% if LANGUAGE == 'kotlin' %}
kotlin {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget("${{JAVA_TARGET}}"))
}
}
${% endif %}


dependencies {


implementation(libs.androidx.appcompat)
implementation(libs.androidx.constraintlayout)
implementation(libs.android.material)
implementation(libs.androidx.startup.runtime)
implementation(libs.androidx.interpolator)
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>

<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name="MainActivity"
android:exported="true">
<intent-filter>
<action
android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.10.2)

project(nativelogdemo C)

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)

add_library(native-log SHARED native-log.c)

# liblog provides __android_log_print and the other <android/log.h> calls.
target_link_libraries(native-log log)
Loading
Loading