加入谷歌游戏服务,以非摇篮的Andr​​oid Studio项目?摇篮、项目、游戏、Andr

2023-09-14 23:02:41 作者:真心真意过一生

我有一个建不摇篮为Android Studio的现有项目 我试图让进口来解决一个谷歌播放服务 java.lang.NoClassDefFoundError的:com.google.android.gms.R $设置样式除了

唯一的问题是,它似乎并不可能......我认为它移植到 摇篮但是codeBase的是相当大的(40 +活动),这将是一个 噩梦像我,以前谁是从未使用过摇篮,来完成。

我试图导入谷歌播放服务项目从SDK,但它 永远挂着创建文件的摇篮。

任何人有加载这个库到非摇篮项目之前的经验吗?

顺便说一句,我试着加载项目到Eclipse,看看我能做到 一些方式,但构建路径自我毁灭的地方,我已经花了几个小时 试图通过它们进行排序无济于事。

解决方案

SDK /额外目录中复制库

使用您的SDK管理器来下载谷歌播放服务 - 它会在其他目录下找到

转到您的Andr​​oid SDK目录,找到谷歌播放services_lib 目录,对我来说这是在Android Studio数据包:

/应用/ Android的Studio.app/sdk/extras/google/google_play_services/libproject/google-play-services_lib/

复制此整个目录到项目的目录。

添加为模块依赖,你通常会。 (对于Android的工作室,请参阅下面一步一步的指导。)的

您将需要一个元标记添加到您的的Andr​​oidManifest.xml 文件,并,看起来是这样的:

<元数据的android:NAME =com.google.android.gms.version             机器人:值=@整数/ google_play_services_version/>

利润和党?

Android的工作室步

步骤到库项目添加为模块依赖,一旦它已经在你的目录。的

文件>导入模块

选择了谷歌播放services_lib 在你的目录目录。

确保 选择创建一个从现有的资源模块,然后单击下一页直到完成向导。

项目结构> 模块(左一)>选择您的应用程序> 依赖设置页> + > 模块依赖> google-玩-services_lib

项目结构> 模块(左一)>选择 google-玩-services_lib > 依赖设置页> +> 罐或目录... >查找并选择库/谷歌播放services_lib /库/谷歌播放services.jar

请务必点击导出复选框这种依赖性。

利润和党?

应用于阿达玛斯皮克曼的感谢帖子为特定的Andr​​oid Studio的步骤。的

JP

I have an existing project that was built without gradle for Android Studio and I'm trying to get Google Play Services imported to fix a java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable exception.

The only problem is it doesn't seem possible... I've considered porting it to gradle but the codebase is rather large (40+ Activities) and it would be a nightmare for someone like me, who's never used gradle before, to accomplish.

I've trying importing the Google Play Services project from the SDK but it hangs forever "creating gradle files".

Anyone have any experience loading this library to a non-gradle project before?

As an aside, I've tried loading the project into Eclipse to see if I could do something that way, but the build paths self-destruct to where I've spent hours trying to sort through them to no avail.

解决方案

Copy the library from the SDK/Extras Directory

Use your SDK Manager to download the Google Play Services - it'll be found under the Extras directory.

Go to your Android SDK directory and find the google-play-services_lib directory, for me this was in the Android Studio package:

/Applications/Android Studio.app/sdk/extras/google/google_play_services/libproject/google-play-services_lib/

Copy this entire directory to your project's libs directory.

Add this as a module dependency as you normally would. (For Android Studio, see below for step-by-step instructions.)

You'll need to add a meta-tag to your AndroidManifest.xml file as well, that looks like this:

<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

Profit and Party?

Android Studio Steps

Steps to add the library project as a module dependency once it's already in your libs directory.

File > Import Module.

Select the google-play-services_lib directory under your libs directory.

Ensure Create module from existing sources is selected and click Next until you finish the wizard.

Project Structure > Modules (far left) > Select Your App > Dependencies tab > + > Module Dependency > google-play-services_lib.

Project Structure > Modules (far left) > Select google-play-services_lib > Dependencies tab > + > Jars or directories... > Find and select libs/google-play-services_lib/libs/google-play-services.jar.

Make sure you click the Export checkbox for this dependency.

Profit and Party?

Many thanks to Adama Speakman's post for the specific Android Studio steps.

JP