我有一个部署到 Android 的 Unity 游戏。
在 Google Play 控制台中,我看到许多在旧 Android 版本 (<=7.1) 上发生的崩溃。崩溃是由 ClassNotFoundException 引起的,但报告没有显示未找到的类。
在崩溃控制台中,我得到以下堆栈跟踪:
java.lang.RuntimeException:
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3025)
at android.app.ActivityThread.-wrap18 (ActivityThread.java)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1565)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:179)
at android.app.ActivityThread.main (ActivityThread.java:6152)
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)
Caused by: java.lang.ClassNotFoundException:
at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass (ClassLoader.java:380)
at java.lang.ClassLoader.loadClass (ClassLoader.java:312)
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3020)
Run Code Online (Sandbox Code Playgroud)
这太通用了,并没有暗示缺少什么类。
我想知道是否有另一种方法可以找到丢失的课程。我正在使用 Multidex(我不知道它是否与问题有关)。
任何帮助将不胜感激在这里..
android unity-game-engine classnotfoundexception android-7.0-nougat android-7.1-nougat
我正在尝试使用我的应用程序测试新功能多窗口,每次我尝试使我的应用程序适合屏幕的一半时,我得到一个吐司说我的应用程序不支持它.
我们如何为Multiple窗口提供单独的布局或单独的活动?
例如.我在android开发者网站的帮助下检查了下面的内容
<activity android:name="com.configure.it.MyScreen">
<layout android:defaultHeight="400dp"
android:defaultWidth="200dp"
android:gravity="top|end"
android:minimalSize="300dp" />
</activity>
Run Code Online (Sandbox Code Playgroud)
通过声明上面的内容,它会影响活动在多窗口模式下的行为方式.
但是,如果在Multiple-Window上激活我的特定屏幕,如何显示不同的布局?
android android-intent android-activity android-n-preview android-7.0-nougat
我正在尝试在Android N中添加一个快速设置切换到我的应用程序.快速图块显示,但点击时它不会执行任何操作.触摸时我可以看到可见的反馈,所以我知道它正在识别点击,但点击时它没有做任何事情.
这是我的服务代码:
public class QuickSettingTileService extends TileService {
public QuickSettingTileService()
{
}
@Override
public IBinder onBind(Intent intent)
{
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startID)
{
//some setup code is here
return START_STICKY;
}
@Override
public void onClick()
{
Context context = getApplicationContext();
Toast.makeText(context, "Quick Setting Clicked", Toast.LENGTH_SHORT).show();
//Toggle code is here
}
}
Run Code Online (Sandbox Code Playgroud)
我的清单几乎直接从文档中复制了代码.只做了一些修改:
<service
android:name=".QuickSettingTileService"
android:label="@string/app_name"
android:icon="@drawable/quick_toggle_off"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
</service>
Run Code Online (Sandbox Code Playgroud)
该服务在打开应用程序时启动:
Intent serviceIntent = new Intent(this, QuickSettingTileService.class);
startService(serviceIntent);
Run Code Online (Sandbox Code Playgroud) dlopen()在API-23上正常工作,但对于Android-N,当我尝试使用dlopen它打开任何sofile 时返回一个soinfo结构类型指针.但当我试图访问此结构的任何变量时,应用程序崩溃.
si = (soinfo*) dlopen("/data/app/com.xxx.xxx.sampleapp.android-1/lib/x86/libtest.so", RTLD_GLOBAL);
if (si == NULL)
return;
LOGI("value of dlopen [%d]", si->size);
Run Code Online (Sandbox Code Playgroud)
dlopen()Android-N的功能是否有任何变化?
我将我的更新android-studio到最新的稳定版本,即“Android Studio 2.3”以及gradle到2.3.0.
现在,当我尝试生成我的应用发布版本的签名 apk 时,这个“额外”的东西(签名版本:) 显示在最后一步:
我点击了“签名帮助”,这个页面被打开了。
我按照文档对我的 build.gradle 文件进行了更改,如下所示:
apply plugin: 'com.android.application'
//Put Fabric plugin after Android plugin
apply plugin: 'io.fabric'
android {
signingConfigs {
config {
keyAlias 'xxxxxx'
keyPassword 'xxxxxx'
storeFile file('/Users/xxxxx')
storePassword 'xxxxxx'
v2SigningEnabled false
}
}
compileSdkVersion 25
buildToolsVersion "25.0.0"
lintOptions {
abortOnError false
}
defaultConfig {
applicationId "com.xxxxx.xxx"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release …Run Code Online (Sandbox Code Playgroud) android android-studio android-7.0-nougat android-7.1-nougat android-studio-2.3
当我开始ble(蓝牙Le)扫描几秒钟,然后停止扫描.然后启动,然后停止......大约5-8次循环后,启动动作将无效,这意味着无法接收扫描记录.1.此条件仅出现在Android 7.0或更高版本(7.1.1); 2.我尝试了两种扫描方法:BluetoothAdapter.startLeScan()和Scanner.startScan(),没有区别.
private void scanToggle(final boolean enable) {
mScanHandler.removeCallbacks(scanTask);
if (enable) {
TelinkLog.i("ADV#scanner#startScan");
scanner = mBluetoothAdapter.getBluetoothLeScanner();
scanner.startScan(null, settings, scanCallback);
mScanning = true;
mDeviceList.clear();
mListAdapter.notifyDataSetChanged();
//mBluetoothAdapter.startLeScan(leScanCallback);
mScanHandler.postDelayed(scanTask, SCAN_PERIOD);
} else {
TelinkLog.i("ADV#scanToggle#stopScan");
mScanning = false;
//mBluetoothAdapter.stopLeScan(leScanCallback);
scanner.stopScan(scanCallback);
}
invalidateOptionsMenu();
}
private BluetoothAdapter.LeScanCallback leScanCallback = new BluetoothAdapter.LeScanCallback() {
@Override
public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) {
TelinkLog.d("scan:" + device.getName());
for (AdvDevice advDevice : mDeviceList) {
if (device.getAddress().equals(advDevice.device.getAddress())) return;
}
mDeviceList.add(new AdvDevice(device, rssi, scanRecord));
runOnUiThread(new Runnable() {
@Override …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用自定义布局在 Android 7 上创建通知,但我想使用 v7 支持库中的 DecoratedCustomView 样式:https : //developer.android.com/reference/android/support/v7/app/ NotificationCompat.DecoratedCustomViewStyle.html
我想使用这种风格的原因是我想使用android提供的通知头,如文档所述:
与提供完全自定义的通知不同,开发人员可以设置此样式并仍然获得系统装饰,例如带有扩展功能和操作的通知标题。
因此,我尝试使用仅包含带有单个 TextView 的 LinearLayout 的 RemoteViews。
final NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
.setWhen(new Date().getTimeInMillis())
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle("title")
.setContentText("text")
.setStyle(new android.support.v7.app.NotificationCompat.DecoratedCustomViewStyle())
.setContent(remoteViews);
Run Code Online (Sandbox Code Playgroud)
结果是一个只包含我的 RemoteViews 的通知,不幸的是没有标题。我刚刚在媒体上找到了一个使用此示例的示例:https : //medium.com/@britt.barak/notifications-part-3-going-custom-31c31609f314
但我无法使用 Android 提供的标头。任何帮助,将不胜感激 :)
android android-appcompat android-notifications android-7.0-nougat
我试图在运行时更改应用程序的语言环境。在API级别24以下的Andorid中,它可以正常工作。但是在API级别24或更高版本中,布局方向不会根据语言环境而变化。下面是在运行时更改语言环境的代码。我使用了如下的LocaleHelper类
public class LocaleHelper {
private static final String SELECTED_LANGUAGE = "Locale.Helper.Selected.Language";
public static Context onAttach(Context context) {
String lang = getPersistedData(context, Locale.getDefault().getLanguage());
return setLocale(context, lang);
}
public static Context onAttach(Context context, String defaultLanguage) {
String lang = getPersistedData(context, defaultLanguage);
return setLocale(context, lang);
}
public static String getLanguage(Context context) {
return getPersistedData(context, Locale.getDefault().getLanguage());
}
public static Context setLocale(Context context, String language) {
persist(context, language);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return updateResources(context, language);
}
return updateResourcesLegacy(context, language);
}
private static String …Run Code Online (Sandbox Code Playgroud) android locale localization android-layout android-7.0-nougat
我发现SeekBar有问题。在具有Android 4,5,6的设备上,我没有这样的问题,但是在具有Android 7的Samsung S8上,出现了进度条问题。如果删除旋转参数,则SeekBar变为水平,问题消失,但是我需要标准的垂直SeekBar。 更新:Nexus模拟器API 24(Android 7)上的相同问题。我已附加了我在Android 6(LG,Sony)和Android 7(Samsung S8)上运行的应用程序的2个屏幕截图和代码:
<SeekBar android:id="@+id/seekBar"
android:layout_width="100dp"
android:layout_height="42dp"
android:background="#20FFFFFF"
android:rotation="270"
android:layout_gravity="center"
>
</SeekBar>
Run Code Online (Sandbox Code Playgroud)
和完整的代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/icon"
android:layout_width="42dp"
android:layout_height="24dp"
android:paddingTop="6dp"
android:background="#20FFFFFF"
android:layout_gravity="center"
android:src="@drawable/iconvolume" />
<LinearLayout
android:layout_width="42dp"
android:layout_height="100dp"
android:gravity="center">
<SeekBar android:id="@+id/seekBar"
android:layout_width="100dp"
android:layout_height="42dp"
android:background="#20FFFFFF"
android:rotation="270"
android:layout_gravity="center"
>
</SeekBar>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)