According to documentation in manifest element
<service android:name=".PrinterService"
should be specifried name of the Service subclass. My subclass is named PrinterService and is defined as following
package arrowsys.vrp.print;
#import
public class PrinterService extends Service {
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
public class PrinterSession extends PrinterDiscoverySession {
}
}
When I put into attribute name .PrinterService
I get
Cannot resolve symbol
With value .service.PrinterService
I get
AidleType package expected, got '.'
Edit: to make it more simple, I have deleted folder arrowsys.vrp.printer/service so my PrinterService.java is directly in arrowsys.vrp.printer.
Now the package definition is package arrowsys.vrp.print
;
Complete AndroidManifest.xaml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="arrowsys.vrp.print">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name="arrowsys.vrp.print.PrinterService"
android:description="@string/app_name"
android:permission="android.permission.BIND_PRINT_SERVICE" >
<intent-filter>
<action android:name="android.vrp.print.PrinterService" />
</intent-filter>
</service>
</application>
</manifest>
As per App Manifest Documentation you have to include the full package path or your service should be a child of the application package
If you define a subclass, as you almost always would for the component classes (Activity, Service, BroadcastReceiver, and ContentProvider), the subclass is declared through a name attribute. The name must include the full package designation. For example, a Service subclass might be declared as follows:
<manifest . . . >
<application . . . >
<service android:name="com.example.project.SecretService" . . . >
. . .
</service>
. . .
</application>
However, if the first character of the string is a period, the application's package name (as specified by the element's package attribute) is appended to the string.
<manifest package="com.example.project" . . . >
<application . . . >
<service android:name=".SecretService" . . . >
. . .
</service>
. . .
</application>
My guess would be that your Manifest package is not arrowsys.vrp.print
, so you'll have to use <service android:name="arrowsys.vrp.print.service.PrinterService">
尝试
<service android:name="arrowsys.vrp.print.service.PrinterService">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.