2014-06-11 5 views
11

Ich habe ein Projekt, das ich auf meinem Computer konfigurieren möchte.Android Studio ignorieren --core-library flag

Auf anothe Computern es funktioniert, aber mit alter Version von Android Studio 0.4.0, wenn ich 0.5.2

Die Proble ist verwenden, nachdem ich es Fehler

Build script error, unsupported Gradle DSL method found: 'coreLibrary()'! Possible causes could be:
- you are using Gradle version where the method is absent - you didn't apply Gradle plugin which provides the method - or there is a mistake in a build script

zeigen starte Anwendung, aber in Um es funktionieren zu lassen, muss ich diese Flagge benutzen! Ich habe bereits versucht, es in den Einstellungen> Android-Compiler zu aktivieren> "Add --core-Bibliothek" Flagge, aber es nutzlos ...

im gradle habe ich nächsten Teil des Codes:

dexOptions { 
    coreLibrary true; 
} 

Dieser Fehler zeigte sich erst nach Aktivierung dieser Zeilen ... Ohne sie funktioniert es nicht ...

WIE SOLLTE ICH DAS FIXEN? Vielleicht liegt es an verschiedenen Versionen. Wenn ja, wie sollte ich schreiben, damit es funktioniert?

Nach dem coreLibrary Ändern = true Es Kompilat Gradle in Ordnung, aber stillen erfordern nach Ausführen --core-Bibliothek Flagge mit .... aber ich gesetzt es bereits in den Einstellungen auf true ...

Es zeigt nicht fast der gleiche Fehler:

Error:Execution failed for task ':BusKg:preDexDebug'. 
> com.android.ide.common.internal.LoggedErrorException: Failed to run command: 
    D:\Programms\Programms\adt-bundle-windows-x86_64-20131030\sdk\build-tools\android-4.4\dx.bat --dex --output D:\Android2\BUS.kg\marshrutka\BusKg\build\pre-dexed\debug\annotations-api-6.0.26-27e56569b50edbdd453f9bc0e568cde1fbfa621b.jar C:\Users\Viacheslav\.gradle\caches\modules-2\files-2.1\org.apache.tomcat\annotations-api\6.0.26\50aeafa144ed17913ed44d18ac61afd505a9e3e\annotations-api-6.0.26.jar 
Error Code: 
    1 
Output: 
    trouble processing "javax/xml/ws/WebServiceRef.class": 
    Ill-advised or mistaken usage of a core class (java.* or javax.*) 
    when not building a core library. 
    This is often due to inadvertently including a core library file 
    in your application's project, when using an IDE (such as 
    Eclipse). If you are sure you're not intentionally defining a 
    core class, then this is the most likely explanation of what's 
    going on. 
    However, you might actually be trying to define a class in a core 
    namespace, the source of which you may have taken, for example, 
    from a non-Android virtual machine project. This will most 
    assuredly not work. At a minimum, it jeopardizes the 
    compatibility of your app with future versions of the platform. 
    It is also often of questionable legality. 
    If you really intend to build a core library -- which is only 
    appropriate as part of creating a full virtual machine 
    distribution, as opposed to compiling an application -- then use 
    the "--core-library" option to suppress this error message. 
    If you go ahead and use "--core-library" but are in fact 
    building an application, then be forewarned that your application 
    will still fail to build or run, at some point. Please be 
    prepared for angry customers who find, for example, that your 
    application ceases to function once they upgrade their operating 
    system. You will be to blame for this problem. 
    If you are legitimately using some code that happens to be in a 
    core package, then the easiest safe alternative you have is to 
    repackage that code. That is, move the classes in question into 
    your own package namespace. This means that they will never be in 
    conflict with core system classes. JarJar is a tool that may help 
    you in this endeavor. If you find that you cannot do this, then 
    that is an indication that the path you are on will ultimately 
    lead to pain, suffering, grief, and lamentation. 
    1 error; aborting 

Vielen Dank im Voraus für jede Hilfe ...

+0

Sind Sie sicher, dass Sie dies tun möchten? Diese Fehlermeldung scheint ziemlich düster. –

+0

Nun ... ich möchte zumindest das Projekt starten und danach versuchen, das zu beheben ... Aber leider weiß ich nicht einmal, wie ich diese Core-Bibliothek aktivieren kann – kimslava93

+0

Wenn Sie nicht bereits tief verstehen, was los ist an und WISSEN, dass Sie diese Flagge aus einem ganz bestimmten Grund brauchen, dann brauchen Sie sie wahrscheinlich nicht. WebServiceRef ist insbesondere eine Annotation für J2EE-Webdienste, die in einer Android-App so gut wie keinen Platz haben. Ich denke, was du versuchst zu tun, macht wahrscheinlich keinen Sinn in Android. –

Antwort

-4

die Syntax für dexOptions Werte spezifiziert ist anders; Sie benötigen ein Gleichheitszeichen:

dexOptions { 
    coreLibrary = true; 
} 
+0

Danke! es half bei der Kompilation von Gradle! Es zeigt keinen Fehler über nicht unterstützte CoreLibrary! Aber es fragt immer noch nach --core-library ... – kimslava93

+0

Sind Sie sicher, dass Gradle tatsächlich diese Flagge unterstützt? Ich habe keine Dokumentation darüber gesehen. –

+0

Ich bin wirklich nicht sicher ... aber ich habe unten meine Frage hinzugefügt, was es zeigt ... und da es bereits fertig ist Projekt ... vorherige Entwickler sagte mir, es zu verwenden ... – kimslava93

0

Ich löste dieses Problem! Leider habe ich es nur durch die Installation der Version Android Studio 0.4.2 gelöst .... Andere Methoden haben nicht geholfen ... Wahrscheinlich ist es später besser, das Projekt für die neue Version von Android Studio zu konfigurieren.

1

Hallo Ich habe das gleiche Problem, und ich beschlossen, es durch überprüft das Feld „Add --core-Bibliothek“ in/Preferences/Compiler/Android Compiler

+0

Fehler: Ausführung der Gradle konnte nicht abgeschlossen werden. Ursache: Unbekannte Befehlszeilenoption '--core-library'. –

2

Ich denke, wir nicht --core-library über dexOptions aktivieren.

Wir wissen, dass dexOptions delegiert zu einem com.android.build.gradle.internal.dsl.DexOptions Objekt, das com.android.builder.core.DexOptions implementiert.

Aus dem Quellcode wissen wir, dass es --core-library nicht unterstützt.

Von Issue 79280: dexOptions in gradle plugin don't support coreLibrary

You can do it manually by

  • disable pre-dexing (this is because our cache would have issues if we allow adding extra params)
  • modify the Dex tasks to add --core-library as an extra parameters.
-1

Sie haben Bibliotheken auszuschließen, die dieses Problem verursachen. Zum Beispiel: -

compile('org.simpleframework:simple-xml:2.7.+'){ 
    exclude module: 'stax' 
    exclude module: 'stax-api' 
    exclude module: 'xpp3' 
} 
5

In Android Studio 1.1.0, navigieren Sie zu:

Datei -> Weitere Einstellungen -> Standardeinstellungen -> Compiler -> Android Compiler

Sie das Kontrollkästchen Hinzufügen "--core-Bibliothek" Flagge finden , aber das scheint nicht zu funktionieren.

Bearbeitung Statt die Datei app/build.gradle

Deaktivieren pre-Dexing innen android {}

dexOptions { 
    preDexLibraries = false 
} 

und Modifizieren Dex task

project.tasks.withType(com.android.build.gradle.tasks.Dex) { 
    additionalParameters=['--core-library'] 
} 

löst das Problem unter Verwendung verwendet wird.

Edit: Vollständiger Inhalt app/build.gradle

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 21 
    buildToolsVersion "21.1.2" 

    defaultConfig { 
     applicationId "appId" 
     minSdkVersion 19 
     targetSdkVersion 21 
     versionCode 1 
     versionName "1.0" 
     multiDexEnabled true 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 

    dexOptions { 
     preDexLibraries = false 
     javaMaxHeapSize "4g" 
    } 

    project.tasks.withType(com.android.build.gradle.tasks.Dex) { 
     additionalParameters=['--core-library'] 
    } 

    packagingOptions { 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/MANIFEST.MF' 
     exclude 'META-INF/DEPENDENCIES' 
     exclude 'META-INF/LICENSE.txt' 
     // more exclude files here if conflicts 
    } 
} 
+0

können Sie nur die Datei 'AndroidManifest.xml' anzeigen? – 4ntoine

+0

Die Änderung ist nicht in AndroidManifest.xml, sondern in app/build.gradle. Aktualisieren der Antwort mit dem Inhalt der Datei. –

+3

funktioniert nicht mehr in AndroidStudio 1.5 –

11
project.tasks.withType(com.android.build.gradle.tasks.Dex) { 
    additionalParameters=['--core-library'] 
} 

nicht richtig funktioniert, und den Fehler:

konnte nicht unbekannte Eigenschaft 'com' erhalten für Objekt vom Typ com.android.build.gradle.AppExtension.

Ich löse das Problem, indem Sie dies zu Android-Block hinzufügen.

dexOptions { 
    preDexLibraries = false 
    additionalParameters=['--core-library'] 
} 

Ich hoffe, dies ist hilfreich für Sie!

+0

dexOptions mit nur zusätzlichen Parametern arbeitete für mich. Vielen Dank – Sriram

Verwandte Themen