質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Q&A

0回答

1066閲覧

使用するandroid端末によってエラーが起こり、アプリが使用出来ません。

shinmo

総合スコア9

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

0グッド

0クリップ

投稿2021/09/04 23:25

編集2022/01/12 10:55

###javaでandroidアプリを制作していますが、使用するandroid端末によって(2台で検証)繰り返し処理のエラーが起こり、アプリが使用出来ません。

IDE:Android Studio 4.1.1

API LevelVer
⑴問題なく使用出来た端末289.0
⑵使用出来なかった端末247.0

発生している問題

上記表⑵の使用出来なかった端末にて
Starting.java(入力文字制限を超える為、コード省略)から”Intent”で画面遷移後のMenuName.java(以下記載)読み込み直後(※問題箇所)の
android\os\Looper.csの中の"public static void loop()"関数にて、

"source code does not match the bytecode"

というエラーが表示され、アプリが強制終了してしまいます。
何が原因と考えられますでしょうか?

該当のソースコード

※プロジェクト名はxxxと表記させて頂いています。

※Starting.javaからラジオボタンを使用し遷移後に以下のMenuName.java読み込み直後にエラー発生する。

MenuName

1package com.example.xxx; 2 3import android.content.Intent; 4import android.os.Bundle; 5import android.view.View; 6import android.widget.Button; 7import android.widget.EditText; 8import android.widget.ImageView; 9import android.widget.RadioGroup; 10import android.widget.Toast; 11 12import androidx.appcompat.app.AppCompatActivity; 13 14 15public class MenuName extends AppCompatActivity { 16 17@Override 18 protected void onCreate(Bundle savedInstanceState) { 19 super.onCreate(savedInstanceState); 20※問題箇所→   setContentView(R.layout.activity_menu_name); 21

R.layout.activity_menu_name↓

<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MenuName"> <ImageView android:id="@+id/imageView9" android:layout_width="1147dp" android:layout_height="952dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.22" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.447" app:srcCompat="@drawable/berrie" /> <Button android:id="@+id/MenuNameButton" android:layout_width="160dp" android:layout_height="51dp" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentBottom="true" android:layout_marginBottom="236dp" android:text="Search" android:textSize="20sp" app:backgroundTint="#A4AAAAAA" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.498" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/MenuName" app:layout_constraintVertical_bias="1.0" /> <EditText android:id="@+id/MenuName" android:layout_width="315dp" android:layout_height="55dp" android:layout_below="@+id/textView2" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_marginStart="8dp" android:layout_marginLeft="8dp" android:layout_marginEnd="8dp" android:layout_marginRight="8dp" android:background="#A6FFFFFF" android:ems="10" android:inputType="textPersonName" android:textColor="@color/black" android:textSize="24sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.353"> <requestFocus /> </EditText> <LinearLayout android:id="@+id/footerlayout2" android:layout_width="match_parent" android:layout_height="48dp" android:layout_alignParentBottom="true" android:background="#00FFFFFF" app:layout_constraintBottom_toBottomOf="parent"> <RadioGroup android:id="@+id/radioGroup" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/purple_200" android:gravity="center|bottom" android:orientation="horizontal"> <RadioButton android:id="@+id/backhome" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:button="@null" android:foreground="@drawable/ic_home_black_24dp" android:foregroundGravity="center" android:gravity="bottom|center" android:textColor="@color/black" android:textSize="10sp" /> <RadioButton android:id="@+id/sarch" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:button="@null" android:foreground="?android:attr/actionModeWebSearchDrawable" android:foregroundGravity="center" android:gravity="bottom|center" android:textAllCaps="false" android:textSize="10sp" /> <RadioButton android:id="@+id/sarch2" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:button="@null" android:foreground="?android:attr/actionModeFindDrawable" android:foregroundGravity="center" android:gravity="bottom|center" android:textAllCaps="false" android:textSize="10sp" /> <RadioButton android:id="@+id/sarch3" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:button="@null" android:foreground="@drawable/add_insert_plus_icon_149546" android:foregroundGravity="center" android:gravity="bottom|center" android:textSize="10sp" /> </RadioGroup> </LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout>

試したこと

▪️PCの再起動

▪️プロジェクトのキャッシュの破棄、再起動

▪️以下のコマンドをターミナルで実行して、Gradleの依存関係をリフレッシュする。

   ./gradlew build --refresh-dependencies

補足情報

gradle

1                                                                                                                         ※以下build.gradle(:app) 2 3plugins { 4 id 'com.android.application' 5} 6 7android { 8 compileSdkVersion 29 9 buildToolsVersion "29.0.3" 10 11 defaultConfig { 12 applicationId "com.example.xxx" 13 minSdkVersion 16 14 targetSdkVersion 29 15 versionCode 1 16 versionName "1.0" 17 18 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 19 } 20 21 buildTypes { 22 release { 23 minifyEnabled false 24 proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 25 } 26 } 27 compileOptions { 28 sourceCompatibility JavaVersion.VERSION_1_8 29 targetCompatibility JavaVersion.VERSION_1_8 30 } 31 32 33} 34 35dependencies { 36 37 implementation 'androidx.appcompat:appcompat:1.2.0' 38 testImplementation 'junit:junit:4.+' 39 implementation 'com.google.android.material:material:1.2.' 40 androidTestImplementation 'androidx.test.ext:junit:1.1.2' 41 androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' 42 implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 43 44 implementation 'com.google.android.material:material:1.2.0' 45 46 47 implementation 'androidx.navigation:navigation-fragment:2.3.2' 48 49 implementation 'androidx.navigation:navigation-ui:2.3.2' 50 implementation 'androidx.vectordrawable:vectordrawable:1.1.0' 51 implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0' 52 implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0' 53 54} 55

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

jimbe

2021/09/05 03:16

確認ですが、コンパイルの対象バージョンの指定であるとか、必要ならサポートライブラリの使用であるとかは大丈夫なのでしょうか。
shinmo

2021/09/05 06:07

jimbeさん コメントありがとうございます。 >>コンパイルの対象バージョンの指定 につきましては、"build.gradle”を追記しました。情報不足で失礼しました。 ですが入力文字数の制限がかかってしまったので、”Starting.java”のコードを省略致しました。(省略しないほうがよければ仰ってください。) >>サポートライブラリの使用 につきましては、使用した事がなかったのでこれから調べてやってみます。
shinmo

2021/09/07 23:51

jimbeさん お待たせしました。 サポートライブラリについてですが、上記の"補足情報"からわかるようにAndroidxが今回それにあたる様で、又サポートライブラリと共存出来ないことから、今回サポートライブラリの導入は不要との認識をしておりますが、合っているでしょうか?ご教授願います。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問