针对Eclipse开发环境,华为提供了下载HMS Core SDK包本地集成的方式。在开始开发前,您需要将HMS Core SDK集成到您的Eclipse开发环境中。
Eclipse SDK下载地址:游戏服务SDK下载

待导入的工程必须和工作空间在相同的磁盘空间里,例如都在“D:\”。如果不在,您可以选择“Copy projects into workspace”,将工程文件复制到工作空间。



<application>
<provider
android:name="com.huawei.agconnect.core.provider.AGConnectInitializeProvider"
android:authorities="${applicationId}.AGCInitializeProvider"
android:exported="false" />
<service
android:name="com.huawei.agconnect.core.ServiceDiscovery"
android:exported="false" />
</application> 将HMSSdkStats工程中assets目录下的资源文件拷贝到您的工程中assets目录下。
如果依赖其他的Kit资源,还需要复制对应Kit的资源文件到您的工程目录下。

打开您的工程的“project.properties”文件,添加如下代码,用于合并子工程中的“Manifest”文件。
manifestmerger.enabled=true
ADT必须是17以上版本。
// TODO: Import the following classes: import java.io.IOException; import java.io.InputStream; import com.huawei.agconnect.config.AGConnectServicesConfig; import com.huawei.agconnect.config.LazyInputStream; import android.app.Application; import android.content.Context; import android.util.Log; public class MyApplication extends Application{ @Override public void onCreate() { super.onCreate(); } // TODO: Add the following code: @Override protected void attachBaseContext(Context context) { super.attachBaseContext(context); AGConnectServicesConfig config = AGConnectServicesConfig.fromContext(context); config.overlayWith(new LazyInputStream(context) { public InputStream get(Context context) { try { return context.getAssets().open("agconnect-services.json"); } catch (IOException e) { return null; } } }); } // TODO: End }
<application android:name=".MyApplication" … > …
您编译APK前需要配置混淆配置文件,避免混淆HMS Core SDK导致功能异常。
-ignorewarnings
-keepattributes *Annotation*
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keepattributes SourceFile,LineNumberTable
-keep class com.huawei.hianalytics.**{*;}
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.hms.**{*;}