2017-02-22 2 views
0

학습 목적으로 안드로이드 앱에서 Google지도를 사용하려고합니다. api 키를 생성했지만이 오류가 발생합니다. 실행 내가 그렇게 나와 함께 곰하시기 바랍니다 안드로이드 응용 프로그램 개발에 새로운 오전? 내가 어떻게 오류를 해결 할 작업 '': app : transformClassesWithDexForDebug'작업 실행에 실패했습니다. in 안드로이드

:app:transformClassesWithDexForDebug'. 
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536 

실패했습니다.

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.user.googlemap"> 

    <!-- 
     The ACCESS_COARSE/FINE_LOCATION permissions are not required to use 
     Google Maps Android API v2, but you must specify either coarse or fine 
     location permissions for the 'MyLocation' functionality. 
    --> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 

    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme"> 

     <!-- 
      The API key for Google Maps-based APIs is defined as a string resource. 
      (See the file "res/values/google_maps_api.xml"). 
      Note that the API key is linked to the encryption key used to sign the APK. 
      You need a different API key for each encryption key, including the release key that is used to 
      sign the APK for publishing. 
      You can define the keys for the debug and release targets in src/debug/ and src/release/. 
     --> 
     <meta-data 
      android:name="com.google.android.geo.API_KEY" 
      android:value="my api key ,i have put it over here " /> 

     <activity 
      android:name=".MapsActivity" 
      android:label="@string/title_activity_maps"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 

</manifest> 

여기는 좀비가 작성한 gradle 빌드 파일입니다.

apply { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.1" 
    defaultConfig { 
     applicationId "com.example.user.googlemap" 
     minSdkVersion 19 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     }a 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:25.0.1' 
    compile 'com.google.android.gms:play-services:10.0.1' 
    testCompile 'junit:junit:4.12' 
} 

변경 한 후 이제이 오류가 발생합니다. * 무엇이 잘못 되었습니까 : ': app'프로젝트를 평가하는 중 문제가 발생했습니다.

org.gradle.api.Project 유형의 'app :'프로젝트에서 인수 [25]에 대한 메소드 compileSdkVersion()을 찾을 수 없습니다.

  • 시도 :
+0

gradble 파일에서 multidex를 활성화하십시오. – zombie

+0

build.gradle 파일을 추가해야합니까? –

+0

@ zombie 어떻게 gradx 파일에서 multidex를 사용할 수 있습니까? –

답변

0

귀하의 오류 ... DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

참고 : 응용 프로그램의 방법 참조의 수는 65K 제한을 초과하는 경우, 응용 프로그램은 컴파일되지 않을 수 있습니다 . 당신은 단지 특정 Google Play 서비스 지정 하여 응용 프로그램을 컴파일 할 때이 문제를 완화 할 수 있습니다 API들 앱

Google Play Services Setup는 (강조 광산)

당신은 참으로 대신 그들 모두의,를 사용 컴파일 "그들 모두는"

compile 'com.google.android.gms:play-services:10.0.1' 

는 당신은지도를 필요로하는 것?

그런 다음 -maps 만 컴파일하십시오.

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 

    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    testCompile 'junit:junit:4.12' 

    compile 'com.android.support:appcompat-v7:25.0.1' 
    compile 'com.google.android.gms:play-services-maps:10.2.0' // See here 
} 

(아니면 Multidex를 활성화 할 수 있습니다 ...하지만 현재의 문제에 대한 잔인한) 그런 다음


, 난 당신이 Gradle을, 파일에 무슨 짓을했는지 모르겠지만,

apply { // <-- Should be android 
    compileSdkVersion 25 

    ... 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     }a // <--- Remove this random 'a' character 
+0

pls 내가 물건을 바꿀 필요가있는 것처럼 설명해 주시겠습니까? –

+0

'/ app/build.gradle' (종속성을 명시하지 않는 것은 아닙니다) –

+0

gradle.build를 업로드했습니다. 변경이 가능합니까? –

0

내가 21 15에서의 minSdkVersion을 변경 한 후, 오늘 유사한 문제를 가지고 라인이 잘 자세한 내용은 여기 https://developer.android.com/studio/build/multidex.html을 확인하시기 바랍니다 작품 다음 사실 multiDexEnabled 추가, 리터 보인다 ike이 문제는 Multidex 지원으로 인해 발생합니다.

+0

"multiDexEnabled true"가 추가 된 후 잘 작동합니다. –

+0

코드를 변경할 수 있습니까? –

+0

이 comment editor는 매우 제한적이기 때문에 defaultconfig 섹션의 gradle 파일에서 ** multiDexEnabled true ** 및 ** minSdkVersion 21 **을 보장합니다. 여기서 텍스트의 형식을 지정하는 방법을 모르지만 생각합니다. 당신은 그것을 바꾸는 방법을 알아야한다. –

관련 문제