平方X 发表于 2016-5-10 08:15:30

Android studio 笔记

记一些小东西,因为自己还不熟悉。
1为什么换as这么晚?
怕电脑运行不起来。

平方X 发表于 2016-5-10 09:27:18

导入eclipse库和删除引用的库
我通过File→New→New Module,添加后,想换个路径,直接移动再import,不行,删除后。造成了一堆麻烦。
查看日志看到settings.gradle:6
去里面看,发现光删除了,里面的引用还在,于是报Error:Project with path '...' could not be found.
删除后不报了。
再回来,为什么直接移动不行,因为我在导入的时候,module又改了相同的名字,导致iml文件是相同的,就不会新建,而是使用iml中的原始配置,而这个配置是需要修改3个地方的。
external.linked.project.id
GRADLE_PROJECT_PATH
external.root.project.path
所以,总结一下步骤
1,File→New→New Module,选择eclipse的库导入
2,Open Module Setting,删除库
3,移动路径,并删除iml文件
4,File→import Module导入
5,可以再改名字,改名字后可能要再改下settings.gradle
6,在settings.gradle中,生成的是一个Test,然后设置了路径。可改为"libs:Test",然后会自动更新的。这样做的好处是,在选择依赖时,可以看到以libs开头的。
7,有时候明明删除了,却说已导入,还是settings.gradle的问题。

整理一下新建的,
1,新建Modeule
2,删除
3,移动,删除iml文件
4,导入
5,修改settings.gradle

平方X 发表于 2016-5-10 13:19:03

local.properties到底能不能修改
[ˈprɒpəti]特性,属性;
在文件中有这样的注释
## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Tue May 10 13:16:56 CST 2016
就是说不让修改,否则也会被清除。不能提交到版本控制。
但是网上签名的又说要改这个方件,到底能不能改呢?

修改sdk.dir后提示,The path "..."does not belong to a directory.
Android studio will use this Android SDK instead:"..." and will modify the project's local.properties file.
然后发现,只是替换了这一个值,之前用户配置的还是存在的。

平方X 发表于 2016-5-10 13:22:36

代码提示 http://my.oschina.net/janson2013/blog/386901
class name complete

平方X 发表于 2016-5-10 13:33:14

配制签名
http://blog.csdn.net/stwstw0123/article/details/48007375


signingConfigs {
    release{
      Properties properties = new Properties()
      properties.load(project.rootProject.file('local.properties').newDataInputStream())
      def store_file = properties.getProperty('signing.release.store_file')
      def store_password = properties.getProperty('signing.release.store_password')
      def key_alias = properties.getProperty('signing.release.key_alias')
      def key_password = properties.getProperty('signing.release.key_password')
      storeFile file(store_file)
      storePassword store_password
      keyAlias key_alias
      keyPassword key_password
    }
}
buildTypes {
    debug {
      signingConfig signingConfigs.release
    }
    release {
      signingConfig signingConfigs.release
    }
}
1,一开始我把方法storeFile和变量store_file重名了
2,试了好多次不行,最后是因为我放到了sourceSets下,应该放到android下。
3,如果密码不正确报下面的
Error:Execution failed for task ':lexiao360:packageDebug'.
> Failed to read key xxx from store "xxx": Cannot recover key

平方X 发表于 2016-5-10 13:34:39

操作行。
不想设置自己的,只好记住它的了。
复制行或块 ctrl+D
移动行 shift+alt+上下
删除行,ctrl+Y

平方X 发表于 2016-5-10 14:49:02

打包so文件http://blog.csdn.net/ocean20/article/details/45675045
打包后百川初始化失败。
查看apk没有so文件,
百度后,加上下面的即可
sourceSets {
    main {
      jniLibs.srcDirs = ['libs']
    }
}

平方X 发表于 2016-5-10 15:48:13

can be simplified to
http://stackoverflow.com/questions/34692950/how-to-disable-android-studio-code-style-warning-can-be-simplified-to
alt+enter后,
setting,去掉。

平方X 发表于 2016-5-12 11:23:16

android studio
关连源码。
点v4包,发现它好像只怎么怎么解压还是干什么的。
后来选了源码,路径在sdk/extras/android,m2repository和support两个里面都有,我还不清楚,有时间看看。
然后就是,根据eclipse,引用的jar我放到libs,是不是可以直接关联,也要再看看。

平方X 发表于 2016-5-12 14:20:32

Android studio
布局时的预览。用tools:text等就可以了。
如果只是调试布局时使用的,可以用这个属性,如果是默认的属性,不要用。
http://tools.android.com/tips/layout-designtime-attributes
http://blog.csdn.net/zhengdan66/article/details/46960985
页: [1] 2
查看完整版本: Android studio 笔记