如何将Microstrategy For Mobile SDK项目从Eclipse转移到Android Studio中?

来源:互联网 发布:怎样成为淘宝直播 编辑:程序博客网 时间:2024/04/27 20:24

最近几个月一直在弄一个项目,需要用到Microstrategy这个东西,研究了很久,最终想把它继承到自己的app中。但是,说起来也挺蛋疼的一件事,Microstrategy针对移动端所提供的SDK完全是忽视了我们安卓阵营,只提供了几个项目文件,让你在他的app上迭加自己的功能,而且本身它项目就已经是很大的了,你若是想加上一些像百度地图那样一些依赖库比较多的功能的话,你铁定谁遇到65535问题。不懂的话,这个还得弄一个星期半死不活。另外,如果手机平台是64位cpu的话。呵呵,那等着官方下一个更新版本吧。而相对来说,ios平台提供的SDK有一套完整的类和接口。可以很自由的在自己的应用中加上它的功能,而不像android这样,只能在它的应用中加上我们的功能。

好了,废话不多说。这次写这篇帖子。主要是方便自己记住将Microstrategy For Mobile SDK项目从Eclipse转移到Android Studio中的过程,以防自己日后忘记。

下面开始正题。

第一步:官方下载将Microstrategy For Mobile SDK文件,解压,然后导入到eclipse中。


图1    解压出来的文件


图 2  将项目导入到eclipse中


第二步:根据官方文档,作简单的定制化操作。参考网址:

https://lw.microstrategy.com/msdz/MSDL/_CurrentGARelease/docs/projects/MobileSDK/default.htm#topics/android/andr_What_Can_You_Do_with_the_Mobile_SDK.htm%3FTocPath%3DMobile%2520SDK%7CMobile%2520SDK%2520for%2520Android%7C_____0

第三步:eclipse导出项目。


图3 选择导出,然后不断选择下一步

第四部:导入android studio。


图4 选择导入AS。

第五步:等待gradle运行完毕,按照提示,将gradle版本更改成对应的版本。manifests中有多余的空格把它去掉(有红色提示)。另外,添加命名空间

xmlns:tools="http://schemas.android.com/tools"  然后,在<application></application>中加入
tools:replace="android:allowBackup"。
第六步:打开下面的gradle文件,加入下面这端代码。
图5 打开build.gradle文件
<pre name="code" class="java">apply plugin: 'android'dependencies {    compile fileTree(dir: 'libs', include: '*.jar')    compile project(':MicroStrategyMobileLibrary')}android {    compileSdkVersion 17    buildToolsVersion "23.0.1"
    packagingOptions {        exclude 'META-INF/NOTICE'        exclude 'META-INF/LICENSE'        exclude 'META-INF/DEPENDENCIES.txt'        exclude 'META-INF/DEPENDENCIES'        exclude 'META-INF/notice.txt'        exclude 'META-INF/license.txt'        exclude 'META-INF/dependencies.txt'        exclude 'META-INF/LGPL2.1'        exclude 'META-INF/ASL2.0'    }    sourceSets {        main {            manifest.srcFile 'AndroidManifest.xml'            java.srcDirs = ['MicroStrategyMobileLibrary_src','src']            resources.srcDirs = ['MicroStrategyMobileLibrary_src','src']            aidl.srcDirs = ['MicroStrategyMobileLibrary_src','src']            renderscript.srcDirs = ['MicroStrategyMobileLibrary_src','src']            res.srcDirs = ['res']            assets.srcDirs = ['assets']        }        // Move the tests to tests/java, tests/res, etc...        instrumentTest.setRoot('tests')        // Move the build types to build-types/<type>        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...        // This moves them out of them default location under src/<type>/... which would        // conflict with src/ being used by the main source set.        // Adding new build types or product flavors should be accompanied        // by a similar customization.        debug.setRoot('build-types/debug')        release.setRoot('build-types/release')    }}
第七步:rebuild项目,然后真机运行。此时会报以下异常。原因是android studio不会自动加载.so文件。
Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.microstrategy.android.samples.app-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libstlport_shared.so"
第八步:修改以下gradle文件。添加代码如下:
图6 打开另一个依赖项目的build.gradle文件
android {    compileSdkVersion 17    buildToolsVersion "23.0.1"    task nativeLibsToJar(type: Zip, description: "create a jar archive of the native libs") {        destinationDir file("$projectDir/libs")        baseName "Native_Libs2"        extension "jar"        from fileTree(dir: "libs", include: "**/*.so")        into "lib"    }    tasks.withType(JavaCompile) {        compileTask -> compileTask.dependsOn(nativeLibsToJar)    }</span>    sourceSets {        main {            manifest.srcFile 'AndroidManifest.xml'            java.srcDirs = ['src']            resources.srcDirs = ['src']            aidl.srcDirs = ['src']            renderscript.srcDirs = ['src']            res.srcDirs = ['res']            assets.srcDirs = ['assets']        }        // Move the tests to tests/java, tests/res, etc...        instrumentTest.setRoot('tests')        // Move the build types to build-types/<type>        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...        // This moves them out of them default location under src/<type>/... which would        // conflict with src/ being used by the main source set.        // Adding new build types or product flavors should be accompanied        // by a similar customization.        debug.setRoot('build-types/debug')        release.setRoot('build-types/release')    }
第九步:rebuild项目,然后真机运行。


0 0
原创粉丝点击