我一直在最困难的时期内仅在Android Studio中运行Google Maps API。除了这一错误,我已经设法解决了大多数错误。
最后一位是
Command: C:\Users\fdher\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\5d744ebf759552512dd49d47a67bee49\aapt2-3.2.0-4818971-windows\aapt2.exe link -I\
C:\Users\fdher\AppData\Local\Android\Sdk\platforms\android-28\android.jar\
--manifest\
C:\Users\fdher\AndroidStudioProjects\FUSARTOURLIFE2\app\build\intermediates\split-apk\debug\resources\AndroidManifest.xml\
-o\
C:\Users\fdher\AndroidStudioProjects\FUSARTOURLIFE2\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
-R\
@C:\Users\fdher\AndroidStudioProjects\FUSARTOURLIFE2\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
--auto-add-overlay\
--java\
C:\Users\fdher\AndroidStudioProjects\FUSARTOURLIFE2\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
--custom-package\
com.example.fdher.fusartourlife\
-0\
apk\
--preferred-density\
420dpi\
--output-text-symbols\
C:\Users\fdher\AndroidStudioProjects\FUSARTOURLIFE2\app\build\intermediates\symbols\debug\R.txt\
--no-version-vectors
Daemon: AAPT2 aapt2-3.2.0-4818971-windows Daemon #0
这是清单文件的样子
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.fdher.fusartourlife">
<user-permission android:name = "android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<user-permission android:name =
"android.permission.ACCESS_COARSE_LOCATION"/>
<user_permission android:name = "android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCFkMk9O7iiPVtrMorVPUTptkv8KCGsPgs"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MapActivity" />
</application>
</manifest>
清单具有两个相同的错误,分别是.MapActivity和.MainActivity
我刚刚开始使用Android Studio,因此,如果我错过了显而易见的事情,请多多关照。预先谢谢你!
编辑:添加了两个build.gradle文件
app build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.fdher.fusartourlife"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support.constraint:constraint-
layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.2'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
}
应用FUSTOURLIFE build.gradle之外的那个
// Top-level build file where you can add configuration options common to
all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
// NOTE: Do not place your application dependencies here; they
// belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是我的string.xml文件
<resources>
<string
name="google_maps_API_key">API_KEY</string>
<string name="app_name">FUSARTOURLIFE</string>
</resources>
这是我的colors.xml文件
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
这是styles.xml文件
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
编辑:答案------------------------------------
在AndroidManifest.xml中添加以下行。
<uses-library android:name="org.apache.http.legacy" android:required="false" />
像魅力一样工作。
答案 0 :(得分:1)
Theme.AppCompat.Light.DarkActionBar样式和缺少的颜色来自AppCompat库。在build.gradle中添加对它的依赖:
implementation 'com.android.support:appcompat-v7:28.0.0'
确保库的版本与您的编译SDK值匹配。
答案 1 :(得分:0)
进行初始设置并查看如何配置google地图,启动android studio并选择Google Maps活动,该活动将自动完成所有这些配置。