标签: android-7.0-nougat

Android N在TextAppearanceSpan中崩溃

自从将Nexus 5X升级到Android N后,使用EditText时出现以下崩溃:

   java.lang.UnsupportedOperationException: Failed to resolve attribute at index 6: TypedValue{t=0x2/d=0x101009b a=1}
       at android.content.res.TypedArray.getColorStateList(TypedArray.java:528)
       at android.text.style.TextAppearanceSpan.<init>(TextAppearanceSpan.java:65)
       at android.text.style.TextAppearanceSpan.<init>(TextAppearanceSpan.java:45)
       at android.widget.Editor$SuggestionsPopupWindow.setUp(Editor.java:3316)
       at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:3016)
       at android.widget.Editor$SuggestionsPopupWindow.<init>(Editor.java:3309)
       at android.widget.Editor.replace(Editor.java:356)
       at android.widget.Editor$3.run(Editor.java:2129)
       at android.os.Handler.handleCallback(Handler.java:751)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6077)
       at java.lang.reflect.Method.invoke(Native Method)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Run Code Online (Sandbox Code Playgroud)

单击已包含某些文本的EditText时会发生这种情况.我假设它是自动正确的弹出窗口或类似的东西.

我的应用程序使用支持库24.2.0和Theme.AppCompat.Light.NoActionBar

编辑:如果我android:colorAccentcolorAccent在我的主题中添加它,它工作正常:

<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/mainBrandColor</item>
    <item name="colorPrimaryDark">@color/mainBrandDarkerColor</item>
    <item name="colorAccent">@color/mainBrandColor</item>
    <item name="android:colorAccent">@color/mainBrandColor</item>
</style>
Run Code Online (Sandbox Code Playgroud)

但是,当我从Theme.AppCompat继承时,不应该这样做.

我做了一个小应用程序,展示了这个问题:

https://github.com/martinbonnin/TextAppearanceSpanCrash/blob/master/app/src/main/java/mbonnin/com/textappearancescancrash/MainActivity.java

android android-support-library android-7.0-nougat

11
推荐指数
1
解决办法
1716
查看次数

android N无法在app billing AIDL中编译

我只是想在Android Studio 2.1 Preview 1中使用新的预览SDK 24 Android N编译我的应用程序.

我在我的应用中使用应用结算.

在尝试构建应用程序时,我得到以下异常

aidl.exe E  6416  3312 io_delegate.cpp:102] Error while creating directories: Invalid argument
Error:Execution failed for task ':app:compileDebugAidl'.
> java.lang.RuntimeException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Gebruiker\AppData\Local\Android\Sdk\build-tools\24.0.0-preview\aidl.exe'' finished with non-zero exit value 1
Run Code Online (Sandbox Code Playgroud)

我已经尝试使用最新的IInAppBillingService.aidl,但我仍然得到相同的错误.当我删除I​​InAppBillingService.aidl文件时,项目编译正常.

这是我构建gradle的一部分

compileSdkVersion 'android-N'
buildToolsVersion "24.0.0 rc1"

defaultConfig {
    applicationId "xxx.myapp"
    minSdkVersion 14
    targetSdkVersion 'N'
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}
Run Code Online (Sandbox Code Playgroud)

IInAppBillingService.aidl文件位于以下文件夹中

src/main/aidl/com/android/vending/billing
Run Code Online (Sandbox Code Playgroud)

如何解决这个问题?

android aidl in-app-billing android-studio android-7.0-nougat

10
推荐指数
1
解决办法
4478
查看次数

无法使用哈希字符串'android-24'找到目标

在此输入图像描述

我改变所有的谷歌图书馆24.0.0和改变后得到这个错误compileSdkVersion,并targetSdkVersion以24正如你在我安装了所有Android n个包装所附的图片看,但只能代表:"部分安装".我怎样才能解决这个问题?

在此输入图像描述

在此输入图像描述

android android-gradle-plugin android-sdk-manager android-7.0-nougat

10
推荐指数
1
解决办法
3万
查看次数

禁用Android N的多窗口功能不适用于某项活动

我想禁用我的应用中的活动的多窗口支持.我resizeableActivity在Manifest中设置为false,但是当我长按最近的应用程序图标时,应用程序仍处于多窗口模式.以下是我的清单:

<activity
    android:name=".MainActivity"
    android:resizeableActivity="false"
    android:excludeFromRecents="true"
    android:icon="@drawable/ic_launcher_home"
    android:theme="@style/AppThemeV3.CustomToolbar">
</activity>
Run Code Online (Sandbox Code Playgroud)

每个文件:

android:resizeableActivity=["true" | "false"]

如果该属性设置为false,则该活动不支持多窗口模式.如果此值为false,并且用户尝试以多窗口模式启动活动,则活动将占据整个屏幕.

我还尝试在清单中的应用程序级别将此属性设置为false,但它仍然以多窗口模式启动.任何关于我做错的指针都会受到高度赞赏吗?

android multi-window android-7.0-nougat

10
推荐指数
1
解决办法
4489
查看次数

Android 7打开APK,ACTION_VIEW无效(包安装程序已停止)

我的应用程序具有自动更新功能,可下载APK,然后使用Intent.ACTION_VIEW打开软件包安装程序.

最多7个它完美地工作(通过向正常文件提供Intent://)

使用Android 7,我不得不改为使用FileProvider.代码的唯一区别是:

Intent installIntent = new Intent(Intent.ACTION_VIEW);
          if (android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
            installIntent.setDataAndType(uri,
                manager.getMimeTypeForDownloadedFile(downloadId));
          } else {

            Uri apkUri = FileProvider.getUriForFile(AutoUpdate.this,
                BuildConfig.APPLICATION_ID, file);
              installIntent.setDataAndType(apkUri,manager.getMimeTypeForDownloadedFile(downloadId));
          }
          activity.startActivity(installIntent);
Run Code Online (Sandbox Code Playgroud)

一旦调用了startActivity,我每次都会得到这个

在此输入图像描述

这是Android 7的错误吗?或者某些/许可缺少我的一面?

编辑AndroidManifest

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.READ_LOGS" />

 <application ...>
 ...
   <provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="com.myapp"
            android:exported="false"
            android:enabled="true"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths"/>
        </provider>
  </application>
Run Code Online (Sandbox Code Playgroud)

路径xmlfile

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path name="myfolder" path="."/> …
Run Code Online (Sandbox Code Playgroud)

crash apk packageinstaller android-7.0-nougat

10
推荐指数
2
解决办法
3080
查看次数

在Android N多窗口模式下按主页按钮时未调用onStop()

我正在努力使我们的视频应用程序支持Android N多窗口模式.我发现活动生命周期在多窗口模式下变得混乱.这种现象是当我们的应用程序布局在顶部屏幕上,整个屏幕是纵向的,然后我点击主页按钮,上层应用程序onPause()调用但未onStop()调用.

根据谷歌指南https://developer.android.com/guide/topics/ui/multi-window.html#lifecycle,视频应用应该在onStop()回调而不是onPause()回调中暂停视频播放.

在这种情况下,按下主页按钮,活动进入后台并变得对用户不可见,我们的应用程序应暂停视频播放但我们无法获得onStop()回调.同时,活动不会触发onMultiWindowChanged()回调,这意味着活动仍处于多窗口模式,尽管它处于后台.在isInMultiWindowMode()将返回true在这种情况下.

当应用程序位于左侧屏幕且整个屏幕处于横向状态时,将出现同样的问题.

我已经搜索了这个问题,发现有人在谷歌上发布了问题,但未在Android Nougat版本中处理.

https://code.google.com/p/android/issues/detail?id=215650&can=1&q=multi%20window%20onstop&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened

那么,什么时候才能在这种情况下暂停我们的视频播放?如果我们在onPause()回调中暂停视频,但在多窗口模式下用户可以看到该活动.如果我们不这样做,我们就无法onStop()在这种情况下获得回调.这类案件是否有适当的解决方法?

android multi-window activity-lifecycle android-7.0-nougat

10
推荐指数
1
解决办法
1047
查看次数

更新android SDK:安装最新平台实现新的API,如"ShortcutManager"

在这里,我正在为Android nougat 应用程序快捷方式中的 Android快捷方式执行演示

我使用以下代码来创建应用程序快捷方式

ShortcutManager shortcutManager;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
    shortcutManager = getSystemService(ShortcutManager.class);
    ShortcutInfo shortcut;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {
        shortcut = new ShortcutInfo.Builder(this, "second_shortcut")
                .setShortLabel(getString(R.string.str_shortcut_two))
                .setLongLabel(getString(R.string.str_shortcut_two_desc))
                .setIcon(Icon.createWithResource(this, R.mipmap.ic_launcher))
                .setIntent(new Intent(Intent.ACTION_VIEW,
                            Uri.parse("https://www.google.co.in")))
                .build();
        shortcutManager.setDynamicShortcuts(Arrays.asList(shortcut));
    }
}
Run Code Online (Sandbox Code Playgroud)

但在这里我得到编译时错误 cannot resolve symbol ShortcutManager.

这是我的build.gradle档案

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.3"
    defaultConfig {
        ...
        minSdkVersion 9
        targetSdkVersion 24
        ...
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies { …
Run Code Online (Sandbox Code Playgroud)

android android-7.0-nougat android-shortcutmanager

10
推荐指数
1
解决办法
520
查看次数

应用程序"继续停止"在Nougat 7.0上

我的应用程序在以前的Android版本上完美运行,在实际设备上从4.0到6.0.1进行了测试.在Studio模拟的Nougat 7.0和7.1中没问题.但是,当我让我的朋友在运行7.0的设备上测试APK时,这会在几秒钟内发生:

崩溃通知

我无法访问该设备(他住的很远)我无法在线找到此特定错误的相关信息.可能是什么原因?

crash android android-7.0-nougat

10
推荐指数
1
解决办法
1万
查看次数

Android:如何在android nougat中编写相机意图

在我的Android应用程序中,我必须使用相机按钮click.It工作完美的所有Android版本除了安卓7(牛轧糖).当我点击相机选项,即使权限打开,应用程序即将退出.我认为问题出在相机调用intent.Below是我的代码.

camera = (ImageView) dialog.findViewById(R.id.camera);

camera.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        clickCamera();
        dialog.dismiss();
    }
});

private void clickCamera() { // 1 for icon and 2 for attachment
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.CAMERA }, MY_REQUEST_CODE);
    } else {
        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, MY_REQUEST_CODE_STORAGE);
        } else {
            currentImageUri = getImageFileUri();
            Intent intentPicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            intentPicture.putExtra(MediaStore.EXTRA_OUTPUT, currentImageUri); // set the image file name
            // start …
Run Code Online (Sandbox Code Playgroud)

camera android android-intent android-7.0-nougat

10
推荐指数
3
解决办法
2万
查看次数

Nougat版本的快捷方式

当我尝试在Intent包中传递Serializable时,我正在捕获这个致命的异常,我认为这与我正在尝试实现的nougat快捷方式有关.这里例外:

12-16 16:17:32.972 20461-20461/***.****.******.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: ***.****.******.debug, PID: 20461
java.lang.IllegalArgumentException: Bad value in PersistableBundle key=shortcutId value=***.****.******.common.cta.CtaAccountSectionModel@1fb70dc
at android.os.PersistableBundle.<init>(PersistableBundle.java:124)
at android.os.PersistableBundle.<init>(PersistableBundle.java:98)
at android.content.pm.ShortcutInfo.fixUpIntentExtras(ShortcutInfo.java:267)
at android.content.pm.ShortcutInfo.<init>(ShortcutInfo.java:245)
 at android.content.pm.ShortcutInfo.<init>(ShortcutInfo.java)
 at android.content.pm.ShortcutInfo$Builder.build(ShortcutInfo.java:1027)
 at ****.******.***.ShortcutHelper.createShortcut(ShortcutHelper.java:79)
 at ****.******.***.ShortcutHelper.refreshShortcuts(ShortcutHelper.java:87)
 at ****.******.***.****.******.***.refreshShortcuts(Application.java:93)
 at ****.******.***.refreshShortcuts(SettingActivity.java:247)
 at ****.******.***.storeShortcuts(SettingActivity.java:242)
 at c****.******.***.access$800(SettingActivity.java:56)
 at ****.******.***.SettingActivity$2.onClick(SettingActivity.java:233)
 at android.view.View.performClick(View.java:5637)
 at android.view.View$PerformClick.run(View.java:22429)
 at android.os.Handler.handleCallback(Handler.java:751)
 at android.os.Handler.dispatchMessage(Handler.java:95)
 at android.os.Looper.loop(Looper.java:154)
 at android.app.ActivityThread.main(ActivityThread.java:6119)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Run Code Online (Sandbox Code Playgroud)

CtaAccountSectionModel.class

public class CtaAccountSectionModel extends CtaModel implements Serializable         {
}
Run Code Online (Sandbox Code Playgroud)

CtaModel.class

@JsonTypeInfo(
            use = JsonTypeInfo.Id.NAME,
            include …
Run Code Online (Sandbox Code Playgroud)

android android-7.0-nougat android-7.1-nougat

9
推荐指数
1
解决办法
1028
查看次数