为什么新建Android要在桌面的Administrator\eclipse新建workspacee\才行,我试过另在其他地方新建,马上就报错

11361人阅读
Android(2)
我们使用Android Studio 运行或测试我们的app &它使用一个默认的debug.keystore进行签名。
这个默认签名(keystore)是不需要密码的,它的默认位置在&$HOME/.android/debug.keystore,如果不存在Android studio会自动创建它。
例如我的debug.keystore就在C:\Users\Administrator\.android\debug.keystore。再我们正式发布项目的时候是不能使用debug.keystore的。
官方地址:&/studio/publish/app-signing.html
下面我们来介绍如何使用Android Studio创建一个新的keystore,并发布我们的apk
第一步: Build ---&& Generate Signed APK
第二步:Create New
第三步:填写相关信息,里面内容什么含义自行Google
第四步:输入密码
第五步:选择发布app的路径默认即可 选择release方式发布
OK,发布成功,可以到文件夹下面找到发布的apk
下面我们来配置如何在debug的时候使用我们自定义的keystore。
第一步:还是要新建一个keystore,就用上面的也可以。
第二步:在项目上右键&Open Module Settings.然后看图就可以了,选择路径,把密码填上,该填的都填好。
第三步:分别选择debug和release 都设置为刚才填进去的keystore。
点击OK即可,然后查看APP的配置文件应该是这样的。
signingConfigs {
android_studio_app {
keyAlias 'androidstudioapp'
keyPassword 'mypassword'
storeFile file('D:/Android/keystore/android_studio_app.jks')
storePassword 'mypassword'
compileSdkVersion 23
buildToolsVersion &23.0.1&
defaultConfig {
applicationId &com.example.administrator.myapplication&
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName &1.0&
buildTypes {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.android_studio_app
signingConfig signingConfigs.android_studio_app
下面讲解如何测试apk是否使用了我们创建的keystore
第一步:&keytool -list -v -keystore &xxx.keystore&
通过工具查看sha1的值.,例如&5C:93:68:2C:E3:2B:00:F1:D6:11:0F:46:08:93:32:1D:FD:6E:60:CC
第二步:在APP内部通过代码的方式获取sha1 两者一比较即可。
import android.content.pm.PackageI
import android.content.pm.PackageM
import android.content.pm.S
import java.io.ByteArrayInputS
import java.io.InputS
import java.security.MessageD
import java.security.NoSuchAlgorithmE
import java.security.cert.CertificateEncodingE
import java.security.cert.CertificateF
import java.security.cert.X509C
//这个是获取SHA1的方法
public static String getCertificateSHA1Fingerprint(Context context) {
//获取包管理器
PackageManager pm = context.getPackageManager();
//获取当前要获取SHA1值的包名,也可以用其他的包名,但需要注意,
//在用其他包名的前提是,此方法传递的参数Context应该是对应包的上下文。
String packageName = context.getPackageName();
//返回包括在包中的签名信息
int flags = PackageManager.GET_SIGNATURES;
PackageInfo packageInfo =
//获得包的所有内容信息类
packageInfo = pm.getPackageInfo(packageName, flags);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
//签名信息
Signature[] signatures = packageInfo.
byte[] cert = signatures[0].toByteArray();
//将签名转换为字节数组流
InputStream input = new ByteArrayInputStream(cert);
//***工厂类,这个类实现了出厂合格证算法的功能
CertificateFactory cf =
cf = CertificateFactory.getInstance(&X509&);
} catch (Exception e) {
e.printStackTrace();
//X509***,X.509是一种非常通用的***格式
X509Certificate c =
c = (X509Certificate) cf.generateCertificate(input);
} catch (Exception e) {
e.printStackTrace();
String hexString =
//加密算法的类,这里的参数可以使MD4,MD5等加密算法
MessageDigest md = MessageDigest.getInstance(&SHA1&);
//获得公钥
byte[] publicKey = md.digest(c.getEncoded());
//字节到十六进制的格式转换
hexString = byte2HexFormatted(publicKey);
} catch (NoSuchAlgorithmException e1) {
e1.printStackTrace();
} catch (CertificateEncodingException e) {
e.printStackTrace();
return hexS
//这里是将获取到得编码进行16进制转换
private static String byte2HexFormatted(byte[] arr) {
StringBuilder str = new StringBuilder(arr.length * 2);
for (int i = 0; i & arr. i++) {
String h = Integer.toHexString(arr[i]);
int l = h.length();
if (l == 1)
if (l & 2)
h = h.substring(l - 2, l);
str.append(h.toUpperCase());
if (i & (arr.length - 1))
str.append(':');
return str.toString();
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:50692次
排名:千里之外
原创:42篇
(2)(4)(7)(2)(3)(2)(7)(7)(7)(1)(1)(3)(4) 上传我的文档
 下载
 收藏
该文档贡献者很忙,什么也没留下。
 下载此文档
正在努力加载中...
Android ***D创建及设置中各参数详解
下载积分:10
内容提示:Android ***D创建及设置中各参数详解
文档格式:DOC|
浏览次数:504|
上传日期: 18:38:00|
文档星级:
该用户还上传了这些文档
Android ***D创建及设置中各参数详解
官方公共微信您所在位置: &
 &  & 
-基于android的文件浏览器的设计与实现(整理版).doc48页
本文档一共被下载:
次 ,您可全文免费在线阅读后下载本文档。
文档加载中...广告还剩秒
需要金币:150 &&
你可能关注的文档:
??????????
??????????
论文分类号:
TN 学校代码: 13681
毕业设计说明书 论文
号: 指导教师: 班
部: 信息工程系 二年月 The Development And Realize of Filebrowser On Android
3G era has slowly integrated into our daily lives, as the country's communications policies and major operators of the impact of propaganda, 3G mobile phones have been everywhere, face of the global information technology unprecedented rapid development of high-speed development of information it is a sign of social progress. In today's global information, mobile phones have become an indispensable daily part of life, especially in the rapidly changing electronic products today, we usually ubiquitous in electronic products, mobile phone users is undoubtedly one of the largest sets, the major smartphone manufacturers of electronic markets is still a bright star. Representative has the promise of which Nokia's Symbian system, Motorola's Linux system, but is still one of the sudden emergence of Google's Andriod open source system for its simplicity and ease of operation must be the future leader in the field of smart phones. We chose this graduation Andriod-based file browser will make our work in the future to provide more opportunities.
With the continuous development of new technologies and applications of Java technology developed rapidly in recent years, a Java application of new technology-based revolution is booming. Andriod-based software development is a prospect of great technology, through the graduation project, we can design the software to the actual experience of the software development process, improve our professional competence, team after team co-operation We can learn teamwork, and ultimately able to obtain a strong expertise.
WORLD: file browser, Android platform, Java technology
基于Android的文件浏览器的开发与实现
3G时代已经慢慢的融入了我们的日常生活
正在加载中,请稍后...

参考资料

 

随机推荐