Tuesday, October 27, 2015

android studio exists with eclipse adt project in same folder

what:
 our old android project is desiged by eclipse with android developer tools(adt),now,we want to used android studio ide to open it.but other co-workers want to used eclipse in same project.

how:
create one build.gradle in eclipse android project:


// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

/////////////////////////////////////////////////////////////////////////////////////////

apply plugin: 'com.android.application'
android {
    compileSdkVersion 22
    buildToolsVersion "23.0.1"
    defaultConfig {
        applicationId "com.your.application.package"        minSdkVersion 10
        targetSdkVersion 22
    }
    
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            jniLibs.srcDirs = ['libs']
        }

//         instrumentTest.setRoot('tests')
    }
    
    buildTypes {
        release {
            minifyEnabled true            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
}



////////////////////////////////////////////////////////////////////
After:
we only add build.gradle with vcs(git,svn). can ignore:
.gradle\
.idea\
bin\
build\
gen\
gradle\
proguard\
*.iml
gradlew
gradlew.bat
local.properties

Tuesday, October 20, 2015

android studio build.gradle default task list simple draft


bellow is andriod studio default task list in right Gradle projects panel:
  assemble
assembleAndroidTest
assembleDebug
assembleRelease
build
buildDependents
buildNeeded
compileDebugAndroidTestSources
compileDebugSources
compileDebugUnitTestSources
compileReleaseSources
compileReleaseUnitTestSources
mockableAndroidJar

bellow is android studio task,if your are so intelligent,your may known how get the easily answer from android studio ide.
By the way,I will simply tell how write build task depends on parameters, if android studio output like:":app:generateDebugSources",your can reference it in app self project by:
    task yourtaskname(dependsOn:['generateDebugSources'])
,if in other proejct,your can reference it by:
    task yourtaskname(dependsOn:[':app:generateDebugSources'])


bellow is default build output log:

Executing tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugAndroidTestSources, :benshoujisdk:generateDebugSources, :benshoujisdk:generateDebugAndroidTestSources, :benshoujisdk:compileDebugSources, :benshoujisdk:compileDebugAndroidTestSources, :benshoujisdkdemo:generateDebugSources, :benshoujisdkdemo:generateDebugAndroidTestSources, :benshoujisdkdemo:compileDebugSources, :benshoujisdkdemo:compileDebugAndroidTestSources, :dynamicloadapklib:generateDebugSources, :dynamicloadapklib:generateDebugAndroidTestSources, :dynamicloadapklib:compileDebugSources, :dynamicloadapklib:compileDebugAndroidTestSources, :sdkbase:generateDebugSources, :sdkbase:generateDebugAndroidTestSources, :sdkbase:compileDebugSources, :sdkbase:compileDebugAndroidTestSources, :sdkproxy:generateDebugSources, :sdkproxy:generateDebugAndroidTestSources, :sdkproxy:compileDebugSources, :sdkproxy:compileDebugAndroidTestSources]

Configuration on demand is an incubating feature.
:clean
:app:clean
:benshoujisdk:clean
:benshoujisdkdemo:clean
:dynamicloadapklib:clean
:sdkbase:clean
:sdkproxy:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl
:app:processDebugAndroidTestManifest
:app:compileDebugAndroidTestRenderscript
:app:generateDebugAndroidTestBuildConfig
:app:generateDebugAndroidTestAssets UP-TO-DATE
:app:mergeDebugAndroidTestAssets
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources
:app:mergeDebugAndroidTestResources
:app:processDebugAndroidTestResources
:app:generateDebugAndroidTestSources
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:processDebugAndroidTestJavaRes UP-TO-DATE
:app:compileDebugAndroidTestJavaWithJavac
:app:compileDebugAndroidTestNdk UP-TO-DATE
:app:compileDebugAndroidTestSources
:benshoujisdk:preBuild UP-TO-DATE
:benshoujisdk:preDebugBuild UP-TO-DATE
:benshoujisdk:checkDebugManifest
:benshoujisdk:preDebugAndroidTestBuild UP-TO-DATE
:benshoujisdk:preDebugUnitTestBuild UP-TO-DATE
:benshoujisdk:preReleaseBuild UP-TO-DATE
:benshoujisdk:preReleaseUnitTestBuild UP-TO-DATE
:sdkbase:compileLint
:sdkbase:copyReleaseLint UP-TO-DATE
:sdkbase:mergeReleaseProguardFiles UP-TO-DATE
:sdkbase:preBuild UP-TO-DATE
:sdkbase:preReleaseBuild UP-TO-DATE
:sdkbase:checkReleaseManifest
:sdkbase:prepareReleaseDependencies
:sdkbase:compileReleaseAidl
:sdkbase:compileReleaseRenderscript
:sdkbase:generateReleaseBuildConfig
:sdkbase:generateReleaseAssets UP-TO-DATE
:sdkbase:mergeReleaseAssets
:sdkbase:generateReleaseResValues UP-TO-DATE
:sdkbase:generateReleaseResources
:sdkbase:packageReleaseResources
:sdkbase:processReleaseManifest
:sdkbase:processReleaseResources
:sdkbase:generateReleaseSources
:sdkbase:processReleaseJavaRes UP-TO-DATE
:sdkbase:compileReleaseJavaWithJavac
:sdkbase:packageReleaseJar
:sdkbase:compileReleaseNdk UP-TO-DATE
:sdkbase:packageReleaseJniLibs UP-TO-DATE
:sdkbase:packageReleaseLocalJar UP-TO-DATE
:sdkbase:packageReleaseRenderscript UP-TO-DATE
:sdkbase:bundleRelease
:benshoujisdk:prepareSdkAndroidStudioSdkbaseUnspecifiedLibrary
:benshoujisdk:prepareDebugDependencies
:benshoujisdk:compileDebugAidl
:benshoujisdk:compileDebugRenderscript
:benshoujisdk:generateDebugBuildConfig
:benshoujisdk:generateDebugAssets UP-TO-DATE
:benshoujisdk:mergeDebugAssets
:benshoujisdk:generateDebugResValues UP-TO-DATE
:benshoujisdk:generateDebugResources
:benshoujisdk:mergeDebugResources
:benshoujisdk:processDebugManifest
:benshoujisdk:processDebugResources
:benshoujisdk:generateDebugSources
:benshoujisdk:prepareDebugAndroidTestDependencies
:benshoujisdk:compileDebugAndroidTestAidl
:benshoujisdk:compileLint
:benshoujisdk:copyDebugLint UP-TO-DATE
:benshoujisdk:mergeDebugProguardFiles UP-TO-DATE
:benshoujisdk:processDebugJavaRes UP-TO-DATE
:benshoujisdk:compileDebugJavaWithJavac
注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。

:benshoujisdk:packageDebugJar
:benshoujisdk:compileDebugNdk UP-TO-DATE
:benshoujisdk:packageDebugJniLibs
:benshoujisdk:packageDebugLocalJar
:benshoujisdk:packageDebugRenderscript UP-TO-DATE
:benshoujisdk:packageDebugResources
:benshoujisdk:bundleDebug
:benshoujisdk:compileDebugSources
:benshoujisdk:assembleDebug
:benshoujisdk:processDebugAndroidTestManifest
:benshoujisdk:compileDebugAndroidTestRenderscript
:benshoujisdk:generateDebugAndroidTestBuildConfig
:benshoujisdk:generateDebugAndroidTestAssets UP-TO-DATE
:benshoujisdk:mergeDebugAndroidTestAssets
:benshoujisdk:generateDebugAndroidTestResValues UP-TO-DATE
:benshoujisdk:generateDebugAndroidTestResources
:benshoujisdk:mergeDebugAndroidTestResources
:benshoujisdk:processDebugAndroidTestResources
:benshoujisdk:generateDebugAndroidTestSources
:benshoujisdk:processDebugAndroidTestJavaRes UP-TO-DATE
:benshoujisdk:compileDebugAndroidTestJavaWithJavac
:benshoujisdk:compileDebugAndroidTestNdk UP-TO-DATE
:benshoujisdk:compileDebugAndroidTestSources
:benshoujisdkdemo:preBuild UP-TO-DATE
:benshoujisdkdemo:preDebugBuild UP-TO-DATE
:benshoujisdkdemo:checkDebugManifest
:benshoujisdk:copyReleaseLint UP-TO-DATE
:benshoujisdk:mergeReleaseProguardFiles UP-TO-DATE
:benshoujisdk:compileReleaseNdk UP-TO-DATE
:benshoujisdk:packageReleaseJniLibs
:benshoujisdk:packageReleaseRenderscript UP-TO-DATE
:benshoujisdk:checkReleaseManifest
:benshoujisdk:prepareReleaseDependencies
:benshoujisdk:compileReleaseRenderscript
:benshoujisdk:generateReleaseResValues UP-TO-DATE
:benshoujisdk:generateReleaseResources
:benshoujisdk:packageReleaseResources
:benshoujisdk:compileReleaseAidl
:benshoujisdk:generateReleaseBuildConfig
:benshoujisdk:generateReleaseAssets UP-TO-DATE
:benshoujisdk:mergeReleaseAssets
:benshoujisdk:mergeReleaseResources
:benshoujisdk:processReleaseManifest
:benshoujisdk:processReleaseResources
:benshoujisdk:generateReleaseSources
:benshoujisdk:processReleaseJavaRes UP-TO-DATE
:benshoujisdk:compileReleaseJavaWithJavac
注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。

:benshoujisdk:proguardRelease


Friday, October 16, 2015

android studio build.gradle quick couse 1 by pkrss



== android studio build.gradle ==

1.define custom variable in module build.gradle:

///////////////////////////////////////////////////////////////////////////////
//

def a = true
def b = "string"

//
///////////////////////////////////////////////////////////////////////////////

2.use if condition variable in module build.gradle:

///////////////////////////////////////////////////////////////////////////////
//

if(a)
    apply plugin: 'com.android.library'
else
    apply plugin: 'com.android.application'

//
///////////////////////////////////////////////////////////////////////////////

3.define custom global whole module variable in one project build.gradle:

///////////////////////////////////////////////////////////////////////////////
//

1. define it in project root build.gradle:
project.ext.set("buildRelease", true)

2.used it in sub module build.gradle:
if(buildRelease)
    apply plugin: 'com.android.library'
else
    apply plugin: 'com.android.application'

//
///////////////////////////////////////////////////////////////////////////////
 
4.define task in build.gradle: (sample with widows path style)

///////////////////////////////////////////////////////////////////////////////
//

def proguardJar(String target){
    exec{
        workingDir './../../tools/guard'
        commandLine 'cmd', '/c', 'proguard5.2.1\\bin\\proguard.bat',"-include", 'profile/' + target + '.txt'
    }
}
def makeJar(String target){
    exec{
        executable "jar"   //jar program
        args "cvf","../../tools/guard/injars/" + target + ".jar"
        args "-C", "../" + target + "/build/intermediates/classes/release"
        args "","."
    }

    proguardJar(target)
}

def releaseDocSource(String ver){
    exec{
        workingDir './../../tools/bat'
        commandLine 'cmd', '/c', 'copyres.bat',ver
    }
}

task buildLib(dependsOn:['build'])<< {
    makeJar("benshoujisdk")
    releaseDocSource("1.1.13")
}

//
///////////////////////////////////////////////////////////////////////////////

5. how to run custom task in android studio

///////////////////////////////////////////////////////////////////////////////
//

it is called 'Gradle projects', in right panel of android studio, then click num 4 button, it likes green ring, and comment  'Execute Gradle Task'. then will open one popup window

line one Gradle project: click right drop button,select one project,
line two Command line: type task name, like above "buildLib"
line three: click ok.
after that,you can see the logs in "Run" or "Gradle Console" panel in the bottom of android studio.

//
///////////////////////////////////////////////////////////////////////////////



6. how to add one exist android studio module in android studio project.

///////////////////////////////////////////////////////////////////////////////
//

copy your exist andriod studio module folder into andriod studio project.
then edit settings.gradle, and add it: include ':your new module folder name'

//
///////////////////////////////////////////////////////////////////////////////

7. what is the shortkey like undo ctrl+z

///////////////////////////////////////////////////////////////////////////////
//

in some editor,it call ctrl+y,but in android studio,default is shirt+ctrl+z
and:
alt+f7: see useage of some class or function
f7: step in
f8: step over
f9: run
esc: close quick search float bar

//
///////////////////////////////////////////////////////////////////////////////

8. add some libs or module or aar depends

///////////////////////////////////////////////////////////////////////////////
//

1.edit your module/build.gradle:
dependencies {
    compile(name: 'CyberLink4Android', ext: 'aar')  // add depends: CyberLink4Android aar
    // compile fileTree(include: ['*.jar'], dir: 'libs')  // add depends: all libs/* jar
    compile 'com.android.support:support-v4:23.0.1'  // add depends: android.support.v4 by online mode
    compile project(':mdns')  // add depends: mdns module project depends
}

//
///////////////////////////////////////////////////////////////////////////////

9. jni ndk developer quickly tip

///////////////////////////////////////////////////////////////////////////////
//

1.install ndk
edit your ndk and sdk path in local.properties,like this:
ndk.dir=D\:\\sdk\\android-ndk-r10e
sdk.dir=D\:\\sdk\\androidsdk

2.copy files into your module/src/main/jni


3.edit gradle.properties,if not exist,create it
android.useDeprecatedNdk=true

4,edit your module build.gradle, like bellow: (some is not need,modify as your need)

android {
    sourceSets.main {
        jniLibs.srcDir 'src/main/libs'
        jni.srcDirs = []
    }
    defaultConfig {

        ndk {
            moduleName "jdns_sd"
            ldLibs "log"
            abiFilters "armeabi", "x86"
            cFlags "-DMDNS_DEBUGMSGS=0 -DTARGET_OS_ANDROID -DUSES_BROADCAST_AND_MULTICAST -DNOT_HAVE_SA_LEN -DUSES_NETLINK" +
                    " -I${project.buildDir}/../src/main/jni -I${project.buildDir}/../src/main/jni/mDNSShared -I${project.buildDir}/../src/main/jni/mDNSCore -I${project.buildDir}/../src/main/jni/mDNSPosix"
        }
    }
    buildTypes {
        release {
            debuggable false
            jniDebuggable false
            minifyEnabled false
        }
        debug {
            debuggable true
            jniDebuggable true
            ndk {
                cFlags "-g -D_DEBUG -UNDEBUG"
            }
        }
    }
}


task genJavaH(dependsOn: ['build']) << {
    exec {
        workingDir 'src/main'
        commandLine 'javah', '-force', '../../build/intermediates/classes/debug', '-o', 'jni/DNSSD.java.h','com.apple.dnssd.AppleDNSSD com.apple.dnssd.AppleBrowser com.apple.dnssd.AppleResolver com.apple.dnssd.AppleRegistration com.apple.dnssd.AppleQuery com.apple.dnssd.AppleDomainEnum com.apple.dnssd.AppleService com.apple.dnssd.AppleDNSRecord com.apple.dnssd.DNSSDEmbedded'
    }
}


//
///////////////////////////////////////////////////////////////////////////////

Monday, October 5, 2015

Today, my Google Play Publisher account has been terminated,and i reply

Part I English

In the morning,i received one email from google.
Here is content:

// start ----------------------------------------------------------------------
This is a notification that your Google Play Publisher account has been terminated.
REASON FOR TERMINATION: Multiple violations of the Content Policy and Developer Distribution Agreement as outlined in previous emails sent to the registered email address of your Publisher account.
Please note that Google Play Publisher terminations are associated with developers, and may span multiple account registrations and related Google services. If you feel we have made an error, you can visit the Google Play Help Center article for additional information regarding this termination.
Please do not attempt to register a new developer account. We will not be restoring your account at this time.
The Google Play Team
// end ----------------------------------------------------------------------

And i replay it with chinese. (english is translated by google and manual)

// start ----------------------------------------------------------------------
This three years. . .

Perhaps because i submitted one software called "Chinese people learning English," English literature or translation application relates to a unit still copyrighted (mostly English literature has indeed been confirmation of protection, and the Chinese translation is extracted from the network) be warned, the application has been shut down already unrecoverable.

There is also a what application, because not landing publishing platform, I really can not remember what a small application, because of what has been shut down.

And because of this, three days before the submission of the night 10.4. "Beauty image" image browsing tool. Because in the content rating review their own in case of multi porn VGH option, or in my own server using flickr, bing, google image search results, or you occasionally review pictures what included some badly result (which I can not yet control the search results). This application shows the default search label, this is Baidu public image Chinese label, the other language labels results are obtained from machine translation.

I beg you to restore the account. "Global voice news king", "voice browser", "古文名著", "中医", Above application are also affected.

In addition, I will modify or delete "Beauty image" image browsing tools, control internet search results, and increase local album browsing, picture browsing effects. Above are the original idea of ​​the application design.

Thank you. Another If you can, please give me detail reason of delete action, such as (machine grading review content, manual review image results).

Also, if for some reason by the impact of certain applications and disrupting the entire developer account, which is not to let individual developers continue to submit creative design acts declared prohibited to google play or world humanity. Consider just some of the applications should be closed so that developers much blow. Developers are not legal experts, your point is that the law's top law professors not necessarily be able to understand, and your notice provisions is so rough, so machinery. Whenever I receive mail in those terms, whether they come from google, microsoft, amazon, paypal ...., mail recipients, including me, how many people will really send on time and careful grinding. . .

                                                                                                                                                                                                                Developers pkrss

 2015.10.6 10:38 am
// end ----------------------------------------------------------------------

Part II 中文

早上,我收到了谷歌发来的邮件.
我回复:

// start ----------------------------------------------------------------------
这三年来。。。

或许是因为之前有提交过”中国人学英文“应用涉及某部还在受版权保护的英文文学或翻译(大部份英文文学已求证确实过保护期,而中文翻译又是从网络摘取)而被警告过,该应用也被已不可恢复的关停。

还有一个什么应用,因为登陆不了发布平台,我真的想不起来是什么小应用,因为什么也被关停。

本次又因为前三天10.4号夜晚才提交的"Beauty image"图片浏览工具。 因为在内容分级审核时,自己以防万一的多钩选了色情选项,或是在自己服务端使用了flickrbinggoogle的图片搜索结果中,偶而包含了某些被你们无意审查到的图片(这暂不是我可以控制的搜索结果)。本应用中默认展示的搜索标签,本是百度公共图片中文标签,使用了机器翻译得出的结果。

烦请恢复账号。因为还有语音新闻王、语音浏览器、中医、古文名著等有特色的应用受牵连。

另外,我会修改或删除"Beauty image"图片浏览工具,尽可能的控制网络搜索结果,并增加本地相册浏览功能,以前图片浏览特效。以上才是本应用设计的原本创意所在。

谢谢。 另如果可以,请告知具体删除的原因,如(机器审核分级内容、人工审核图片结果)。

还有,如果因为一些应用受某些原因的影响而中断整个开发者账号,这不是让个人开发者持续向google play或是世界全人类提交创意设计的行为宣告为禁止。考虑一下只是关闭某些应用就应该很让开发者倍受打击了。另外开发者不是法律专家,你们的那点法律条文就是最顶级的法律教授也不一定能够理解,而且你们通知条款又是那么的粗糙、那么的机器。每当我邮箱中收到那些条款,不管他们来自googlemicrosoftamazonpaypal.... 包括我在内的邮件接收者,有多少人会真的时间发在上而仔细研磨。。。

                                                                                                                                                                                                                开发者  pkrss

 2015.10.6早上1038
// end ----------------------------------------------------------------------