java - 在java构建路径下添加google play服务库

标签 java android eclipse google-play-services

我正在使用 map View 。我已将 Google Play 服务库作为依赖项目添加到我的项目中,并且运行良好。但是如果我尝试将它导入我项目的 libs 文件夹并将它添加到 java 构建路径下,它会出错。

我可以在 java 构建路径下添加 google play 服务库吗?如果不是,为什么?

错误显示在 控制台:

[2015-03-17 13:10:28 - LifeScience] '\\Dragon\d\Android\eclipse'
[2015-03-17 13:10:28 - LifeScience] CMD.EXE was started with the above path as the current directory.
[2015-03-17 13:10:28 - LifeScience] UNC paths are not supported.  Defaulting to Windows directory.
[2015-03-17 13:10:28 - LifeScience] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager
[2015-03-17 13:10:28 - LifeScience] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager$CaptionStyle
[2015-03-17 13:10:28 - LifeScience] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager$CaptionStyle
[2015-03-17 13:10:28 - LifeScience] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager$CaptionStyle
[2015-03-17 13:10:28 - LifeScience] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager$CaptionStyle
[2015-03-17 13:10:28 - LifeScience] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager$CaptionStyle
[2015-03-17 13:10:28 - LifeScience] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager
[2015-03-17 13:10:28 - LifeScience] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager
[2015-03-17 13:10:28 - LifeScience] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager$CaptionStyle
[2015-03-17 13:10:28 - LifeScience] Warning: com.google.android.gms.dynamic.b: can't find referenced method 'android.app.Fragment getParentFragment()' in class android.app.Fragment
[2015-03-17 13:10:28 - LifeScience] Warning: com.google.android.gms.fitness.service.FitnessSensorService$a: can't find referenced class android.app.AppOpsManager
[2015-03-17 13:10:28 - LifeScience] Warning: com.google.android.gms.fitness.service.FitnessSensorService$a: can't find referenced class android.app.AppOpsManager
[2015-03-17 13:10:28 - LifeScience] Warning: com.google.android.gms.games.internal.PopupManager$PopupManagerHCMR1: can't find referenced method 'android.view.Display getDisplay()' in class android.view.View
[2015-03-17 13:10:28 - LifeScience] Warning: com.google.android.gms.internal.an$2: can't find referenced method 'void evaluateJavascript(java.lang.String,android.webkit.ValueCallback)' in class android.webkit.WebView
[2015-03-17 13:10:28 - LifeScience] Warning: com.google.android.gms.internal.gp: can't find referenced method 'java.lang.String getDefaultUserAgent(android.content.Context)' in class android.webkit.WebSettings
[2015-03-17 13:10:28 - LifeScience] Warning: com.google.android.gms.internal.gp: can't find referenced method 'void setMediaPlaybackRequiresUserGesture(boolean)' in class android.webkit.WebSettings
[2015-03-17 13:10:28 - LifeScience] Warning: com.google.android.gms.internal.gv: can't find referenced method 'void evaluateJavascript(java.lang.String,android.webkit.ValueCallback)' in class android.webkit.WebView
[2015-03-17 13:10:28 - LifeScience]       You should check if you need to specify additional program jars.
[2015-03-17 13:10:28 - LifeScience] Warning: there were 11 unresolved references to classes or interfaces.
[2015-03-17 13:10:28 - LifeScience]          You may need to specify additional library jars (using '-libraryjars').
[2015-03-17 13:10:28 - LifeScience] Warning: there were 6 unresolved references to program class members.
[2015-03-17 13:10:28 - LifeScience]          Your input classes appear to be inconsistent.
[2015-03-17 13:10:28 - LifeScience]          You may need to recompile them and try again.
[2015-03-17 13:10:28 - LifeScience]          Alternatively, you may have to specify the option 
[2015-03-17 13:10:28 - LifeScience]          '-dontskipnonpubliclibraryclassmembers'.
[2015-03-17 13:10:28 - LifeScience] java.io.IOException: Please correct the above warnings first.
[2015-03-17 13:10:28 - LifeScience]     at proguard.Initializer.execute(Initializer.java:321)
[2015-03-17 13:10:28 - LifeScience]     at proguard.ProGuard.initialize(ProGuard.java:211)
[2015-03-17 13:10:28 - LifeScience]     at proguard.ProGuard.execute(ProGuard.java:86)
[2015-03-17 13:10:28 - LifeScience]     at proguard.ProGuard.main(ProGuard.java:492)

请帮我解决这个问题。

编辑

我已将 dontwarn 添加到我的 proguard.txt 文件中,现在我可以导出我的应用程序了。

proguard-project.txt

    -keepclassmembers class fqcn.of.javascript.interface.for.webview {
   public *;
}

-keep class * extends java.util.ListResourceBundle {
    protected Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}

-dontskipnonpubliclibraryclasses
-dontwarn com.google.**
-dontwarn android.support.v4.**

我在谷歌上搜索过,但我不清楚 dontwarn 的概念。谁能解释一下 dontwarn 的作用以及在混淆时使用它是否安全?

最佳答案

您必须将 google-play-services-lib 添加为库项目。他们更新了 SDK。周围有几个教程。对于 Eclipse,这很容易:

Right click project -> properties -> Android

enter image description here

关于java - 在java构建路径下添加google play服务库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29092785/

相关文章:

android - 调用 popupwindow 的 showAtLocation 会使应用程序崩溃

eclipse - "Computing additional info"是什么意思?

android abortBroadcast 不会停止广播短信

java - Eclipse 没有响应,停留在初始化 Java 工具 30%

java - Jersey servlet 的 web.xml 不响应请求

java - 使用 Java、Slick2D 和平铺 map 编辑器进行碰撞检测

java - 如何在Frame中添加JPanel

java - RenderResponse 中的 TimeoutException(不知道为什么)

java - 如何使用 Liferay Maven 的 Service Builder 创建插件?

android - 我可以使用 Apache Cordova 从 AVD 中选择特定的 Android 设备模拟器吗?