我想知道为什么没有坚定的合作方式Jackson
.我只想解析JSON
字符串:
ObjectMapper mapper = new ObjectMapper();
Customer[] myObjects = mapper.readValue(file, Customer[].class);
Run Code Online (Sandbox Code Playgroud)
但我真的很困惑应该导入什么来做到这一点.根据这个链接,我试图导入mapper-asl.jar
.但我得到这个编译错误:
The type org.codehaus.jackson.JsonParser cannot be resolved. It is indirectly referenced from required .class files
Run Code Online (Sandbox Code Playgroud)
然后我尝试导入jackson-core-2.4.2
和jackson-databind-2.4.2
.所以没有编译错误,但我得到了这个运行时异常(在mapper定义行中):
java.lang.NoClassDefFoundError: com.fasterxml.jackson.annotation.JsonAutoDetect
Run Code Online (Sandbox Code Playgroud)
请指导我,我应该导入哪些内容Jackson
.谢谢
我有两个使用相同自定义帐户类型的应用.这两个应用程序是完全独立的,只是共享帐户.当其中一个启动时,它会检查现有的自定义帐户,如果未找到任何帐户,则会显示登录页面.
所以我创建了我AccountAuthenticator
的图书馆项目并在两个应用程序中引用它.根据本教程:
假设您将验证者的代码复制到了2个应用程序中,从而共享其逻辑,并更改每个应用程序上的登录页面设计以适合其所属的应用程序.在这种情况下,当请求auth-token时,将为两个应用程序调用第一个安装的应用程序的身份验证器.如果您卸载第一个应用程序,将从现在开始调用第二个应用程序的身份验证器(因为它现在是唯一的一个).
当我运行其中一个应用程序(无论哪个应用程序)并调用addAccount
它时,它会很好地显示登录页面.然后,当我运行第二个应用程序并且调用addAccount
没有任何反应时,并且不会显示登录页面.卸载第一个应用程序后,第二个应用程序正常工作并显示登录页面.那么问题是什么,我该如何解决?
执行addAccount
:
mAccountManager.addAccount(accountType, authTokenType, null, null, this, new AccountManagerCallback<Bundle>() {
@Override
public void run(AccountManagerFuture<Bundle> future) {
try {
Bundle bnd = future.getResult();
showMessage("Account was created");
} catch (Exception e) {
e.printStackTrace();
showMessage(e.getMessage());
}
}
}, null);
Run Code Online (Sandbox Code Playgroud)
提前致谢
account android accountmanager android-authenticator android-account
这是我的Activity
:
public class MainActivity extends AppCompatActivity {
private SoundPool soundPool;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setVolumeControlStream(AudioManager.STREAM_MUSIC);
soundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
final int sound1 = soundPool.load(this, R.raw.whack, 1);
final int sound2 = soundPool.load(this, R.raw.miss, 1);
Button b1 = (Button) findViewById(R.id.b1);
Button b2 = (Button) findViewById(R.id.b2);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
playSound(sound1);
}
});
b2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
playSound(sound2);
}
});
}
private void playSound(int soundId) …
Run Code Online (Sandbox Code Playgroud) 我有一个CoordinatroLayout
带FloatingActionButton
.这是我的代码:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar_layout"
android:layout_above="@+id/actionbar">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="120dp"
android:minHeight="?android:attr/actionBarSize"
android:background="@color/toolbar_color" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
</ScrollView>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
app:fabSize="mini"
android:src="@mipmap/ic_action_edit"
app:layout_anchor="@id/toolbar"
app:layout_anchorGravity="bottom|right|end"
app:backgroundTint="@color/toolbar_color" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
但它在棒棒糖和棒棒糖前装置中看起来有所不同.
棒糖:
其实我没有添加任何保证金.但FAB在棒棒糖前设备方面有优势.
我也在cheessesquare样本中看到过这个问题.它也显示出不同的边距.问题是什么?
android android-layout floating-action-button android-coordinatorlayout
我有两个使用相同帐户类型的应用.我希望当用户第一次打开第二个应用并且存在一个帐户时,会显示以下页面:
但是当我运行这段代码时没有任何反应:
final AccountManagerFuture<Bundle> future = mAccountManager.getAuthToken(account, authTokenType, null, this, null, null);
new Thread(new Runnable() {
@Override
public void run() {
try {
Bundle bnd = future.getResult();
final String authtoken = bnd.getString(AccountManager.KEY_AUTHTOKEN);
showMessage((authtoken != null) ? "SUCCESS!\ntoken: " + authtoken : "FAIL");
Log.d("udinic", "GetToken Bundle is " + bnd);
} catch (Exception e) {
e.printStackTrace();
showMessage(e.getMessage());
}
}
}).start();
Run Code Online (Sandbox Code Playgroud)
当我从具有验证器的应用程序运行它时,上面的代码正常工作.当我在代码下面运行时,系统会生成一个通知,当我点击它时,会出现上面的图片.
final AccountManagerFuture<Bundle> future = mAccountManager
.getAuthToken(account, authTokenType, null, true,
null, handler);
Run Code Online (Sandbox Code Playgroud)
单击允许按钮可AuthToken
正确返回.但是我希望在通话时看到授权许可页面(上图)getAuthToken
,而不是点击通知.我怎样才能做到这一点?
我zxingfragmentlib
在github上使用一个简单的条形码扫描器片段.
它运作良好.但是当我以扫描模式离开设备时,它会在3或4分钟后崩溃.
我在logcat中看到的唯一(红色)东西是:
10-14 14:37:42.914: E/dalvikvm(11025): Unexpected opcode(263) with kInstrCanBranch set
10-14 14:37:42.914: E/dalvikvm(11025): VM aborting
10-14 14:37:42.914: A/libc(11025): Fatal signal 6 (SIGABRT) at 0x00002b11 (code=-6), thread 11033 (Compiler)
Run Code Online (Sandbox Code Playgroud)
有什么问题,我该如何解决?
提前致谢!
在我的课程中,Android Studio分析显示发现了1个错字:
我知道错别字标有下划线,但要搜索所有代码都很难。有没有更容易找到错别字的方法?
警告和错误带有黄色和红色标记,但我看不到任何错别字标记。
谢谢
我将json
某些对象的表示形式保存为应用程序中的缓存。更新应用程序的每个发行版之后我都没有问题,并且json
对象已正确转换为Java对象。更新到android gradle plugin 3.5之后(添加此行):
classpath 'com.android.tools.build:gradle:3.5.0'
Run Code Online (Sandbox Code Playgroud)
当我创建发行版apk时,似乎无法将json
字符串转换为java对象,并且混淆的名称似乎已更改。当我将其还原到gradle插件3.4.2时,一切正常。那么问题是什么,我该如何解决?
android proguard gradle android-studio android-gradle-plugin