ApiDemosアプリはAndroid Developersのサンプルとしては提供されておらず、別途 Android GoogleSourceリポジトリからダウンロードする必要が有ります。
※もともとEclipseでビルドすることを想定している(README.txt参照)ためそのままでは現在の AndroidStudioでAPKをビルドすることはできません。
【ダウンロード先】ApiDemos
(1) Android.bp ※ビルドに必要な情報が書かれています
package {
// See: http://go/android-license-faq
default_applicable_licenses: ["Android-Apache-2.0"],
}
android_test {
name: "ApiDemos",
// Only compile source java files in this apk.
srcs: [
"src/**/*.java",
"src/com/example/android/apis/app/IRemoteService.aidl",
"src/com/example/android/apis/app/IRemoteServiceCallback.aidl",
"src/com/example/android/apis/app/ISecondary.aidl",
],
static_libs: [
"androidx-constraintlayout_constraintlayout",
"androidx.legacy_legacy-support-v4",
],
sdk_version: "current",
dex_preopt: {
enabled: false,
},
test_suites: ["device-tests"],
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
}
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=true
android.enableJetifier=true
sdk.dir=/home/yourname/Android/Sdk
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "ApiDemos"
include ':app'
plugins {
id 'com.android.application'
}
android {
namespace 'com.example.android.apis'
compileSdk 31
defaultConfig {
applicationId "com.example.android.apis"
minSdk 31
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.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
}
// AIDLファイルのパスを指定する
sourceSets {
main {
aidl.srcDirs = ['src/main/aidl']
}
}
}
dependencies {
// androidx.constraintlayout, androidx.legacyの2つに置き換える
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
[src/com/example/android/apis/app配下の全てのAIDLファイル(*.aidl)を下記のパッケージにコピーする]
aidl/com/example/android/apis/app/
IRemoteService.aidl
IRemoteServiceCallback.aidl
ISecondary.aidl
asstes/
[解凍したソースのasstesを全てコピーする]
java/
[プロジェクトのソースを全て削除し、解凍したソースのsrc配下を全てコピーする]
com/example/android/
apis/
mmslib
res/
[プロジェクトのリソースを全て削除し、解凍したソースのres配下を全てコピーする]
anim/
animator/
drawable/
drawable-hdpi/
layout/
...[省略]...
menu/
...[省略]...
values/
values-hdpi/
...[省略]...
values-xlarge/
xml/
tests/
AndroidManifest.xml
Executing tasks: [:app:assembleDebug] in project /mnt/data-2/ApiDemos
>Task :app:createDebugVariantModel
>Task :app:preBuild UP-TO-DATE
>Task :app:preDebugBuild UP-TO-DATE
>Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
>Task :app:compileDebugRenderscript NO-SOURCE
>Task :app:generateDebugBuildConfig
>Task :app:javaPreCompileDebug
>Task :app:generateDebugResValues
>Task :app:checkDebugAarMetadata
>Task :app:mapDebugSourceSetPaths
>Task :app:generateDebugResources
>Task :app:compileDebugAidl
>Task :app:createDebugCompatibleScreenManifests
>Task :app:extractDeepLinksDebug
>Task :app:mergeDebugResources
>Task :app:processDebugMainManifest FAILED
package="com.example.android.apis" found in source AndroidManifest.xml:
/mnt/data-2/ApiDemos/app/src/main/AndroidManifest.xml.
...Warning省略...
...ここからError (見やすくするため改行をいれています) 363箇所 ...
/mnt/data-2/ApiDemos/app/src/main/AndroidManifest.xml:70:9-76:20 Error:
android:exported needs to be explicitly specified for element
.
Apps targeting Android 12 and higher are required to specify an explicit value for
`android:exported` when the corresponding component has an intent filter defined.
See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
Apps targeting Android 12 and higher are required to specify an explicit value for
`android:exported` when the corresponding component has an intent filter defined.
<activity android:name="ApiDemos">
<activity android:exported="true" android:name="ApiDemos">