As an experiment, and as a way to force myself to understand the ins and outs of how tts works on Android, I thought it might be interesting to copy the source code for the TextToSpeech class into a new class in my project and rename it (and it's package name) to that of my project.
This of course results in many classes getting highlighted in red and needing to be re-attached and brought into my project as well.
So I began the process of repeating the same procedure -- copying the source of each missing class into a new class in my project -- which leads to more missing classes within that new class.
I was expecting these errors to happen, but in theory I was hoping it would be possible to graft the whole android.tts.* "tree" (or whatever parts were necessary in order to make the TextToSpeech class function) into my project.
Here's my code to illustrate:
MainActivity.java:
public class MainActivity extends AppCompatActivity {
// notice that this not android.speech.tts.TextToSpeech class, but a local copy of it.
MyTextToSpeech tts;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tts = new MyTextToSpeech(getApplicationContext(), new MyTextToSpeech.OnInitListener() {
#Override
public void onInit(int i) {
if (i == TextToSpeech.SUCCESS) {
begin();
}
else {
Log.i("XXX", "init failed");
}
}
}, "com.google.android.tts");
}
private void begin() {
Log.i("XXX", "It seems to have initialized!");
}
}
I've gotten rid of most of the errors in my "custom" TextToSpeech class (plz just assume this error is the only one remaining), but there is this one class that I can't seem to pull into the project: ITextToSpeechService:
Apparently this is a hidden/internal "aidl" file the source of which is here.
I tried pasting it in a new folder named "aidl" (following this answer) and it "worked" in the sense that it existed in the aidl folder without errors, but when trying to compile it using gradle\tasks\other\compileDebugAidl, I got this error:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:compileDebugAidl'.
1 exception was raised by workers:
java.lang.RuntimeException: java.lang.RuntimeException: java.io.IOException: com.android.ide.common.process.ProcessException: Error while executing process /Users/boober/Library/Android/sdk/build-tools/28.0.3/aidl with arguments {-p/Users/boober/Library/Android/sdk/platforms/android-29/framework.aidl -o/Users/boober/Desktop/SCRAP/TTSGraft/app/build/generated/aidl_source_output_dir/debug/out -I/Users/boober/Desktop/SCRAP/TTSGraft/app/src/main/aidl -I/Users/boober/Desktop/SCRAP/TTSGraft/app/src/debug/aidl -I/Users/boober/.gradle/caches/transforms-2/files-2.1/1cd7eff88f5e86d0249af2958bf465f0/core-1.1.0/aidl -I/Users/boober/.gradle/caches/transforms-2/files-2.1/929ec10604c047a76453df3294ada6ae/versionedparcelable-1.1.0/aidl -d/var/folders/vz/d68y33c14pjc9m2vrkqp2kvc0000gn/T/aidl4956045951058849495.d /Users/boober/Desktop/SCRAP/TTSGraft/app/src/main/aidl/com/booberbunz/ttsgraft/ITextToSpeechService.aidl}
... and it still would not resolve within MyTextToSpeech.java.
How to get this file into my project locally so that I no longer have the "can't resolve error" in red as seen in image?
And as an aside question: is this actually not possible to do -- to hardcode tts into a project?
Thanks.
I just added those AIDLs to a project and compile them. I've just added both ITextToSpeechService.aidl and ITextToSpeechCallback.aidl and removed imports, modified packages and added ITextToSpeechCallback import to ITextToSpeechService:
import com.android.speech.tts.ITextToSpeechCallback;
My files were under src/main/aidl/com/android/speech/tts
so the package in AIDLs is:
package com.android.speech.tts;
Related
Okay, so I've tried to import my unity project as a single activity in Android Studio.
I've followed this
tutorial
but I kept getting an error at step 6:
"Unable to resolve dependency for ‘:app#debug/compileClasspath’: Could not resolve project..."
So I turned to another tutorial on a different way to import the aar package to my main project file in android studio.
Now, using both of the tutorials together, I managed to put something together that will compile without an error.
This is my main activity, where I want to start the unity activity on a button click:
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void startUnity(View view){
Intent intent = new Intent(this.getApplicationContext(), UnityPlayerActivity.class);
startActivity(intent);
}
}
The UnityPlayerActivity class is recognized by Android Studio, but when I run the app, I get this exception:
"Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.zackguetta.foodiedoodie/com.unity3d.player.UnityPlayerActivity}; have you declared this activity in your AndroidManifest.xml?"
How do I fix this? I thought the merge of the manifests would take care of this.
*note: I'm using Android Studio 3.0.1 if it means anything to you (maybe some compatibility issues arise)
*second note: Yes, I went through the other similar topics, none seemed to have the answer, so please don't mark as a duplicate right away.
Add it to your AndroidManifest.xml. Write this line inside <application> tags:
<activity android:name=".unity3d.player.UnityPlayerActivity" />
I managed to integrate grooid into my plain android project, so it could compile, with all those lint, multidex magic (yes, I fixed 65k limit problem), and successfully run on a device
Then I created a src/main/groovy folder, moved one of my java activities into it and turned it to a groovy class:
package com.mypackage
#CompileStatic
class SplashActivity extends Activity {
void onCreate( Bundle savedInstanceState ) {
super.onCreate savedInstanceState
contentView = R.layout.splash
}
}
upon compiling, I get a compile errors like:
:app:compileDebugJavaWithJavac
AuthHelper.java:25: error: cannot find symbol
import com.mypackage.SplashActivity;
^
symbol: class SplashActivity
So, the groovy files must be somehow compiled before compile*JavaWithJavac.
How can this be done?
If you place the java files into the groovy folder the groovy compiler will facilitate joint compilation.
You can also use the skipJavaC flag to get joint compilation as well see https://github.com/groovy/groovy-android-gradle-plugin#only-use-groovyc for more information.
I am creating simple android application in android of hello world printing and getting an -- error Description
Resource Path Location Type Error generating final archive: java.lang.ArrayIndexOutOfBoundsException: 13 Demo_ABC Unknown Android Packaging Problem
Code is:
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity
{
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Someone else had the same problem with eclipse. The solution was to check the box "Create Test Project":
Your project is getting associated with some Test Project which you are not mapping with your newly created project. When you are creating any new project check carefully whether you are including the "Create Test Project" option or not.
Another guess: As the error seems to be package-related and your code does not include that, insert the correct package yourpackage.tld; in the code. (you said "Code is:").
Maybe that is missing Android expects it by default and gives weird errors because that was totally unforseen by the Google Android developers.
I have two classes in a different projects.
I am importing the project that has the class that I need.
Now, I have no errors.
The project know's that class and I even made an object from that class, but when I'm trying to run it it crushes with the "NoClassFoundError".
How can i fix that?
import com.dmg.pixelservice.core.*;
import android.app.Activity;
import android.os.Bundle;
public class show extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Pixel pixel = new Pixel();
pixel.doIt(this,"fd7ccf36-3f85-11e1-8671-40409e0f44a1",true);
setContentView(R.layout.main);
}
}
When I debug, I can see that it crashes when I'm trying to do Pixel pixel = new Pixel();
Please help.
create new libs folder in your application .name must be same.and put your jar files in this folder.and
go to
java Build Path -> Configure Build Path -> Add jars
Looks like the jar file containing the Pixel class is not packaged into the APK.
To make that happen, it seems you need to copy the jar into the libs folder of your Android project.
See this question:
Approach for fixing NoClassDefFoundError?
Android Developer Guide:
http://developer.android.com/guide/developing/projects
it is easy to find the error if you send the src code of your Pixel class.
I've looked and looked, but Eclipse (3.6, with the 2.2 Android SDK) just won't do anything with the AIDL file I created. The AIDL file is in the same place as the other source, following the Java style. I've read that Eclipse should just generate the stub for the interface declared in the AIDL file, but it doesn't appear in the gen folder, nor anywhere else i've seen, and the project doesn't build because the interface specified in the AIDL isn't found. I suspect i'm doing something silly or not understanding something, but as much as i've looked and tried, I still don't get it and Eclipse still fails.
My AIDL:
package com.example.helloandroid;
interface HOSPlayerInterface
{
public void playURL(String url);
public boolean pause();
public boolean resume();
public void stop();
}
... and said AIDL lives in the com/example/helloandroid directory. Eclipse isn't recognizing it, highlighting syntax, running AIDL, etc. I'm at a loss. The Android plugin is installed and working, as i'm able to build and run simple Android projects that don't require AIDL. Any help would be appreciated.
Just remove all "public" access modifier before method declaration. The following code works in my project.
package com.example.helloandroid;
interface HOSPlayerInterface {
void playURL(String url);
boolean pause();
boolean resume();
void stop();
}
If the aidl file can not get compiling in Eclipse, delete "gen" folder and rebuild the project.
Any build errors? The IDE might exit prior to compiling your .aidl-file due to parse errors in XML or similar.