1.API22=>API26 으로 업데이트 이후 앱에서 사진불러오기를 하는데 오류가 발생합니다.
Caused by: android.os.FileUriExposedException: file:///storage/emulated/0/tmp_1543123435953.jpg exposed beyond app through Intent.getData()
at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)
at android.net.Uri.checkFileUriExposed(Uri.java:2346)
at android.content.Intent.prepareToLeaveProcess(Intent.java:9510)
at android.content.Intent.prepareToLeaveProcess(Intent.java:9468)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1525)
at android.app.Activity.startActivityForResult(Activity.java:4389)
at android.app.Activity.startActivityForResult(Activity.java:4348)
at com.xxxxx.xxxxxx.activity.join.Join2Activity.onActivityResult(Join2Activity.java:393)
at android.app.Activity.dispatchActivityResult(Activity.java:7226)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4443)
2.오류가 발생하는 소스 부분입니다.
startActivityForResult(intent, CROP_FROM_CAMERA); <= 여기서 오류 발생
case PICK_FROM_CAMERA:
{
// 이미지를 가져온 이후의 리사이즈할 이미지 크기를 결정합니다.
// 이후에 이미지 크롭 어플리케이션을 호출하게 됩니다.
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(mImageCaptureUri, "image/*");
intent.putExtra("outputX", 500);
intent.putExtra("outputY", 500);
// 크롭 비율
intent.putExtra("aspectX", 0);
intent.putExtra("aspectY", 0);
intent.putExtra("scale", true);
// Crop한 이미지를 저장할 Path
intent.putExtra(MediaStore.EXTRA_OUTPUT, mImageCaptureUri); // 임시파일 생성
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
startActivityForResult(intent, CROP_FROM_CAMERA);
break;
}
3.그래서 찾아가보니 \SDK\sources\android-26\android\app\Activity.java파일 안에 아래 import 들이 모두 빨간색 오류 표시가 납니다..
import android.annotation.CallSuper;
import android.annotation.DrawableRes;
import android.annotation.IdRes;
import android.annotation.IntDef;
import android.annotation.LayoutRes;
import android.annotation.MainThread;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.StyleRes;
import android.annotation.SystemApi;
import android.content.IIntentSender;
import android.os.ServiceManager.ServiceNotFoundException;
import android.os.SystemProperties;
import android.util.Slog;
import android.util.SuperNotCalledException;
import android.view.ViewRootImpl;
import android.view.ViewRootImpl.ActivityConfigCallback;
import android.view.Window.WindowControllerCallback;
import android.view.WindowManagerGlobal;
import android.view.autofill.AutofillPopupWindow;
import android.view.autofill.IAutofillWindowPresenter;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.app.IVoiceInteractor;
import com.android.internal.app.ToolbarActionBar;
import com.android.internal.app.WindowDecorActionBar;
import com.android.internal.policy.DecorView;
import com.android.internal.policy.PhoneWindow;
2.Project - build gradle 내용
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
//classpath 'com.google.gms:google-services:4.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
3.app - build gradle내용
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.xxxx.xxxxx"
minSdkVersion 15
targetSdkVersion 26
versionCode 34
versionName "1.33"
}
signingConfigs {
release {
storeFile file("xxxxxxx")
storePassword "xxxx"
keyAlias "xxxxx"
keyPassword "xxxxx"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}
dependencies {
api fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:22.0.1'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.google.android.gms:play-services:8.3.0'
implementation files('libs/glide-3.6.1.jar')
implementation files('libs/jsoup-1.8.3.jar')
}
##왜 이런 오류가 발생하는거죠?아무리 찾아봐도 알수가 없네요 초보자에겐 너무 어렵습니다.
제가 뭘 잘못 한건지 고수님들 한수 부탁 드리겠습니다.~