报错:
Error:FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not download parse-android.jar (com.parse:parse-android:1.13.1)
> Could not get resource 'https://jcenter.bintray.com/com/parse/parse-android/1.13.1/parse-android-1.13.1.jar'.
> Could not GET 'https://jcenter.bintray.com/com/parse/parse-android/1.13.1/parse-android-1.13.1.jar'.
> Connection reset
> Could not download crashreport.aar (com.tencent.bugly:crashreport:2.6.6.1)
> Could not get resource 'https://jcenter.bintray.com/com/tencent/bugly/crashreport/2.6.6.1/crashreport-2.6.6.1.aar'.
> Could not GET 'https://jcenter.bintray.com/com/tencent/bugly/crashreport/2.6.6.1/crashreport-2.6.6.1.aar'.
> Connection reset
> Could not download nativecrashreport.aar (com.tencent.bugly:nativecrashreport:3.3.1)
> Could not get resource 'https://jcenter.bintray.com/com/tencent/bugly/nativecrashreport/3.3.1/nativecrashreport-3.3.1.aar'.
> Could not GET 'https://jcenter.bintray.com/com/tencent/bugly/nativecrashreport/3.3.1/nativecrashreport-3.3.1.aar'.
> Connection reset
> Could not download push-internal.aar (com.meizu.flyme.internet:push-internal:3.7.0)
> Could not get resource 'https://jcenter.bintray.com/com/meizu/flyme/internet/push-internal/3.7.0/push-internal-3.7.0.aar'.
> Could not GET 'https://jcenter.bintray.com/com/meizu/flyme/internet/push-internal/3.7.0/push-internal-3.7.0.aar'.
> Connection reset
分三步走:
第一步:项目build.gradle在jcenter()后边加上:{url 'http://jcenter.bintray.com/'}
repositories {
google()
jcenter(){url 'http://jcenter.bintray.com/'}
}
第二步:改掉用户名/.gradle/gradle.properties文件夹,去掉里面的代理,
第三步:rebuild project.
解决
附赠一个保存view图片到相册的工具类:
public Bitmap getBitmapFromView(View view) {
int w = view.getWidth();
int h = view.getHeight();
Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bmp);
view.layout(0, 0, w, h);
view.draw(c);
// 缩小图片
Matrix matrix = new Matrix();
matrix.postScale(2f, 2f); //长和宽放大缩小的比例
bmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);
return bmp;
}
public void SaveBitmapFromView(View view) {
int w = view.getWidth();
int h = view.getHeight();
Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bmp);
view.layout(0, 0, w, h);
view.draw(c);
// 缩小图片
Matrix matrix = new Matrix();
matrix.postScale(2f, 2f); //长和宽放大缩小的比例
bmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);
DateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
saveBitmap(bmp, format.format(new Date()) + ".JPEG");
}
public void saveBitmap(Bitmap bitmap, String bitName) {
String fileName;
File file;
if (Build.BRAND.equals("Xiaomi")) { // 小米手机
fileName = Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera/" + bitName;
} else { // Meizu 、Oppo
fileName = Environment.getExternalStorageDirectory().getPath() + "/DCIM/" + bitName;
}
file = new File(fileName);
if (file.exists()) {
file.delete();
}
FileOutputStream out;
try {
out = new FileOutputStream(file);
// 格式为 JPEG,照相机拍出的图片为JPEG格式的,PNG格式的不能显示在相册中
if (bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out)) {
out.flush();
out.close();
// 插入图库
MediaStore.Images.Media.insertImage(this.getContentResolver(), file.getAbsolutePath(), bitName, null);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// 发送广播,通知刷新图库的显示
this.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + fileName)));
}