2015年7月21日 星期二

Android Studio import .aar & Eclipse lib project

# Import aar

  1. File --> New... --> New Module --> import .JAR or .AAR package, choose the specific aar file
  2. Add dependency
    File--> project structure ---> choose app(or other module use the lib)--> dependancies
    Add the imported module

    Or edit build.gradle directly:
    dependencies {
        compile project(
    ':resourceHosting' )
        compile project(
    ':iotivity-armeabi-v7a-base-debug' )
    }
  3. Sync gradle & build 



# Import aar -2

http://blog.csdn.net/qiujuer/article/details/39754517
NOTE: 這個方法在import多個aar時會出錯
如果兩個aar都有包多個.so檔,package的時候只會包到其中一個aar的.so檔

# Import eclipse project

  1. File-->New... --> Import Library... --> Choose the eclipse project folder
  2. Choose all option, press Finish
  3. Edit AndroidManifest.xml to remove wrong properties
    (Remove all properties with error)

  4. Edit build.gradle of the imported module
    Change apply plugin: 'com.android.application'
    to 
    apply plugin: 'com.android.library'
  5. Edit build.gradle remove other wrong fields, like applicationId
  6. Add dependency as described above
  7. Sync gradle & build 

2015年5月12日 星期二

[Android] 解決setsockopt在multicast的問題

參考以下這一篇
http://developerweb.net/viewtopic.php?id=5784

原因是Android開Wi-Fi AP Mode之後
系統把routing table寫死成只有內網(192.168.xx)才有route
因為目前預設的multicast IP是寫死成224.0.1.187

Setsocketopt找不到route就失敗了

Work around:
route add -net 224.0.0.0 netmask 224.0.0.0 dev ap0