2016-08-04 36 views
1

我寫了一個使用com.gluonhq.charm.down.common.ScanService的小樣本。它在預期的真實iOS設備上工作,if我手動將本機庫libCharm.a包含在src/ios/jniLibs中。這在他們的GoNative應用程序的膠合文檔中有解釋。如果我沒有弄錯,該庫建立在Charm Down IOS的​​build.gradle文件中。Gluon Mobile項目可以自動下載幷包含libCharm.a嗎?

這是我的示例的build.gradle。正如我所說的,如果我將libCharm.a手動複製到src/ios/jniLibs,會導致完全運行的應用程序。

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'org.javafxports:jfxmobile-plugin:1.0.8' 
    } 
} 

apply plugin: 'org.javafxports.jfxmobile' 

repositories { 
    jcenter() 
    maven { 
     url 'http://nexus.gluonhq.com/nexus/content/repositories/releases' 
    } 
} 

mainClassName = 'com.thomaskuenneth.scanservicedemo.ScanserviceDemo' 

dependencies { 
    compile 'com.gluonhq:charm:3.0.0' 

    androidRuntime 'com.gluonhq:charm-android:3.0.0' 
    androidRuntime 'com.google.zxing:core:3.2.1' 

    iosRuntime 'com.gluonhq:charm-ios:3.0.0' 

    desktopRuntime 'com.gluonhq:charm-desktop:3.0.0' 
} 

jfxmobile { 

    apply plugin: 'idea' 
    idea.module.downloadJavadoc = true 

    android { 
     manifest = 'src/android/AndroidManifest.xml' 

     androidSdk = '/Users/thomas/Library/Android/sdk' 
     compileSdkVersion = 23 
    } 
    ios { 
     infoPList = file('src/ios/Default-Info.plist') 
     forceLinkClasses = [ 
       'com.google.zxing.**.*', 
       'com.gluonhq.**.*', 
       'io.datafx.**.*', 
       'javax.annotations.**.*', 
       'javax.inject.**.*', 
       'javax.json.**.*', 
       'org.glassfish.json.**.*' 
     ] 
    } 
} 

,我打算給iosRuntime依賴性增加魅力向下-IOS的最新版本,但是這似乎沒有任何效果。所以,問題是:有沒有辦法自動獲得符合我指定依賴關係的libCharm.a,或者是手動方式(哪一個可以工作)唯一可能的方式?非常感謝你提前。

回答

2

截至目前,該插件中沒有自動工具用於管理本地庫的正確安裝,從charm-down-ios.jar中提取它並將其移動到項目的jniLibs庫中。但它應該在未來版本的插件中可用。

現在,你必須做手工,正如你所說,提取將位於您的本地資源庫的.m2的charm-ios-3.0.0.jarlibCharm.a文件,src/ios/jniLibs下將它複製到你的項目。

我來到了這個任務,這將幫助你做到這一點:

task extractNativeLib(type: Sync) { 
    def iosNativeDir = project.file(project.jfxmobile.ios.nativeDirectory) 
    if (!iosNativeDir.exists()) { 
     iosNativeDir.mkdirs() 
    } 

    setIncludeEmptyDirs(false) 
    from { 
     configurations.iosRuntime.collect { zipTree(it).matching { include 'native/**' } } 
    } 
    into iosNativeDir 
    eachFile {details -> details.path = details.name } 
} 

運行此任務調用launchIOSDevice之前,它會提取出庫,並將其複製到本地文件夾中。

編輯

由於javafxmobile插件1.1.0(十月2016)的發佈也沒有必要使用此任務,因爲這個插件將對其進行管理。

對於項目中包含的Charm Down 3.0.0+插件,它們的本機庫將自動添加到構建以及src/ios/jniLibs中包含的任何其他第三方本機庫。

+0

太棒了。一如既往,何塞,你的回答非常感謝。非常感謝您的大力支持。 – Thomas

相關問題