[英]Google Maps api2 with Android Studio issue
我使用Eclipse将多个Google Maps v1转换为v2,没有很多问题。 我的一项服务大量使用了V1 GeoPoint类,通过导入import com.google.android.maps.GeoPoint
,我能够使用未更改的代码。 我有六个使用此GeoPoint类运行Maps V2的应用程序。
现在,我在Android Studio上结束了将我的最后一个Maps V1应用程序转换为Maps V2的工作,但是,即使我具有相同的import语句,当我引用GeoPoint类时在运行时也会遇到异常。 说...
NoClassDefFoundError:无法解决以下问题:Lcom / google / android / maps / GeoPoint。
因此,相同的代码在Eclipse中进行测试时可以正常运行,而在Android Studio中进行测试时则可以正常运行。
编辑:GeoPoint类在AS中编译良好,它只是在运行时就崩溃了。 我不知道是什么原因造成的。
如果有帮助,则包括清单文件和Build.gradle
模块。
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:21'
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.deanblakely.mttTrial"
minSdkVersion 10
targetSdkVersion 21
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':library')
compile 'com.android.support:support-v4:21.0.3'
compile 'com.google.code.gson:gson:2.2.2'
compile 'com.google.android.gms:play-services:+'
}
表现:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.deanblakely.mttTrial"
android:versionCode="22"
android:versionName="2.22" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="21" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="false"
android:xlargeScreens="true" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name="com.deanblakely.mttTrial.PSActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity
android:label="@string/app_name"
android:name="com.deanblakely.mttTrial.LicenseCheck"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<uses-library android:name="com.google.android.maps" />
</activity>
<service
android:name="com.deanblakely.mttTrial.StalkService"
android:exported="false" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="not the actual key" />
<!--' Release key is not the actual release key'-->
<!--' Debug key is not the actual debug key'-->
</application>
<!-- Required permission to check licensing. -->
<uses-permission android:name="com.android.vending.CHECK_LICENSE" />
</manifest>
改善您的build.gradle
compile 'com.google.android.gms:play-services:5.0.89'
并添加您的Manifest
<uses-permission android:name="com.deanblakely.mttTrial.permission.MAPS_RECEIVE" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.