切换ndk-build到gradle-build

接到一个任务

将现有的ndk-build 切换到gradle build

一开始是网上找资料 +现有项目的gradle脚本东拼西凑   能够buildsuccessful  

但是出来的apk  你都不知道是哪里出错导致的

 

 

 

 

然后开始了control +c /v 大法

找现成的 gayhub 搜索gradle jni android

 

 

 ./gradlew build    

报错Android home  没定义 添加local.properties

test@qemu05:~/zhekun/gradlebuild/Android-hello-jni_Gradle$ cat local.properties
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains @R_375_4045@ion specific to your local configuration.

# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=/home/test/env/sdk
#ndk.dir=/home/test/env/ndk/21.3.6528147
ndk.dir=/home/test/env/ndk/r20b

报错

A problem occurred evaluating root project 'hello-jni'.
> Failed to apply plugin [id 'android']
> Gradle version 2.10 is required. Current version is 5.4.1.

解决方法并设置环境变量  但是后来好像没解决

 

wget https://downloads.gradle-dn.com/distributions/gradle-2.1-all.zip

test@qemu05:~/zhekun/gradlebuild/Android-hello-jni_Gradle$ cat ~/.bashrc|grep gradle
export PATH=/home/test/zhekun/gradlebuild/gradle-2.2/bin:$PATH

然后换了一种执行方式

 

 

 这年头拿来主义也不容易啊

 

 

 

compileSdkVersion:编译时的环境,与运行时无关。把这个设置成最高,可以避免使用被弃用的API。

minSdkVersion:app软件运行时支持的最低的Android版本。

targetSdkVersion:创建Android项目使用的API版本。使用低版本API就能实现的功能就不要用更高的API版本,因为高版本API可能导致程序的不兼容,影响app在不同安卓版本手机中的显示效果。但也要注意,高版本API会修复和完善低版本中出现的问题,提供更多更好的类和接口给开发者使用。同时高版本API也会新增一些方法属性,以前多行代码才能搞定的事,现在可能只要一行代码就能搞定。

===========================================================

 

 

开始将公司的代码结构转移到这个helloworld

很明显AndroidManifest.xml这里的  package="com.intel.btft.androidlog"要按照jni目录结构改

/home/test/zhekun/gradlebuild/Android-hello-jni_Gradle/src/com/intel/btft/androidlog

 

刚刚不知道改了什么

build successful

然后还没高兴几秒钟 被我改fail了

看来定时备份很重要啊 TAT

 

 

FAILURE: Build Failed with an exception.

* What went wrong:
Task 'build.gradle' not found in root project 'androidlog'.

 

相关文章

安装环境都很简单,就是下载工具需要在华为开发者联盟里注册...
上传的方式有两种,第一种是通过bintray官方出的插件bintray...
转载自: 完美解决Error:SSLpeershutdownincorrectly打开gr...
https://www.jianshu.com/p/9220227cdfb3buildscript{ext.ko...
Markdown版本笔记我的GitHub首页我的博客我的微信我的邮箱My...
 跟着教程做的,已经有了JDK,直接进行后面的步骤,下载安装...