• andorid开发build.gradle 增加几种产品的方法


    因为需要有些ndk的开发,cmakelists里需要定义不同的变量,这个在网上搜索解决方案,不是很容易就直接找到答案。

    尝试了不少,最后找到解决方案。升级Gradle3.0,这个文章价值高。

    在raspi平台下,需要使用到androidthings的库,但全志的R16平台下,支持的android版本低,没有androidthings的库。我就这样做的。

    1. 修改 几个app和依赖cpp库的build.gradle和androidmanifest.xml文件。

    app的build.gradle加入了:

    flavorDimensions "platform"
    productFlavors {
    raspi {
    dimension "platform"
    minSdkVersion 23
    buildConfigField 'String', "THINGSLIB", "com.google.android.things"
    applicationId 'com.estone.uvc.raspirf4463test'
    targetSdkVersion 27
    versionCode 1
    versionName '1.0'
    versionNameSuffix '-ras'
    }
    r16 {
    dimension "platform"
    minSdkVersion 19
    buildConfigField 'String', "THINGSLIB", ""
    applicationId 'com.estone.uvc.raspirf4463test'
    targetSdkVersion 27
    versionCode 1
    versionName '1.0'
    versionNameSuffix '-r16'
    }
    }

    依赖库的buid.gradle这样修改:
        flavorDimensions "platform"

    productFlavors {
    r16 {
    dimension "platform"
    minSdkVersion 19
    targetSdkVersion 23
    buildConfigField 'String', "THINGSLIB", ""
    testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
    versionCode 1
    versionName '1.0'
    externalNativeBuild {
    cmake {
    arguments "-DPLATFORM=R16"
    }
    }
    // applicationIdSuffix ".r16"
    }
    raspi {
    dimension "platform"
    minSdkVersion 23
    targetSdkVersion 27
    buildConfigField 'String', "THINGSLIB", "com.google.android.things"
    versionCode 1
    versionName '1.0'
    externalNativeBuild {
    cmake {
    arguments "-DPLATFORM=RASPI"
    }
    }
    }
    }

    rapsi的minisdkversion不能是19,定义THINGSLIB,是要传导到androidmanifest.xml中。
    每个app和依赖库的androidmanifest.xml都这样修改:
    <!--<uses-library android:name="com.google.android.things" />-->
    <uses-library android:name="${THINGSLIB}" />

    2. 修改依赖库的CMakeLists.txt文件,

    set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../../../libandroidthings)
    find_package(AndroidThings REQUIRED)


    add_library(bsp4463 SHARED
    RF4463.cpp RF4463.h radio_config_Si4463.h RF4463_JNI.cpp)

    target_include_directories(bsp4463 PRIVATE
    ${PROJECT_DIR}/android-system-properties
    ${ANDROID_NDK}/sources/android/native_app_glue
    ${ANDROIDTHINGS_INCLUDE_DIRS})

    if(PLATFORM STREQUAL "RASPI")
    add_library(androidthings SHARED
    IMPORTED)
    set_target_properties(androidthings
    PROPERTIES IMPORTED_LOCATION
    ${ANDROIDTHINGS_LIBRARIES})
    endif()

    if(PLATFORM STREQUAL "RASPI")
    ADD_DEFINITIONS(-D__RASPI)
    target_link_libraries(bsp4463
    android
    log
    androidthings)
    else()
    target_link_libraries(bsp4463
    android
    log)
    endif()

    依赖库(Cpp库)的build.gradle,通过 arguments "-DPLATFORM=RASPI",把参数传入到cmake中,cmake中检查变量PLATFORM,……。

    
    
  • 相关阅读:
    周赛D. Digging for Gold(扫描线)
    CF1209F Koala and Notebook(最短路+拆点)
    P6793 [SNOI2020]字符串(后缀树上DP)
    [HEOI2016/TJOI2016]字符串(后缀自动机,可持久化线段树,线段树合并,二分答案)
    CF1166F Vicky's Delivery Service(并查集,启发式合并)
    P4248 [AHOI2013]差异(后缀树)
    CF1175F The Number of Subpermutations(单调栈,ST表)
    CF666E Forensic Examination(后缀自动机,可持久化线段树合并)
    GYM103069G. Prof. Pang's sequence
    [转]C#、VB.NET使用HttpWebRequest访问https地址(SSL)的实现
  • 原文地址:https://www.cnblogs.com/tangxiaosheng/p/10362405.html
Copyright © 2020-2023  润新知