Android CMake compiled project using Gradle to generate APK


(The Insidious One) #1

I am new to gradle and have no idea how to make an already compiled library and executable into an Android package.

This is the build.gradle file:

 apply plugin: 'com.android.application'
//apply plugin: 'kotlin-android'
//apply plugin: 'kotlin-android-extensions'

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {                 
    repositories {
        google()
        jcenter()
    }
    dependencies {            
        classpath 'com.android.tools.build:gradle:3.0.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {                 
    repositories {
        google()
        jcenter()
    }
}

android {
    compileSdkVersion 16
    buildToolsVersion "27.0.3"

    defaultConfig {
        applicationId "com.solventer.deviceviewer"
        minSdkVersion 16
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
        ndk.abiFilters 'armeabi-v7a'
    }

    sourceSets {
    // Encapsulates configurations for the main source set.
    	main {
      // For each source set, you can specify only one Android manifest.
      // By default, Android Studio creates a manifest for your main source
      // set in the src/main/ directory.
      		manifest.srcFile 'AndroidManifest.xml'
      		jniLibs.srcDirs 'build-device-controller-CMake_Android_for_armeabi_v7a_GCC_4_9_Qt_5_10_1_armeabi_v7a-Debug',
      						'/opt/android-qt5/5.10.1/armeabi-v7a/lib'
    	}
	}

    buildTypes {
        debug {
            signingConfig null
        }
        release {
            signingConfig null
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    externalNativeBuild {

    	// Encapsulates your CMake build configurations.
    	cmake {
    		//arguments "-DANDROID=1", "APP_STL=gnustl_static", "NDK_TOOLCHAIN_VERSION=4.9", "APP_OPTIM=release", "V=1"
    		path "CMakeLists.txt"
    	}
  	}

	flavorDimensions "mode"
  	productFlavors {
    	fullDebug {
    		dimension "mode"
    	}
	}
}

// 11
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.+'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}